:root {
  --orange: #f18815;
  --orange-dark: #c96500;
  --brown: #2d2118;
  --brown-2: #493324;
  --cream: #f7f3ed;
  --cream-2: #efe6da;
  --paper: #ffffff;
  --ink: #17120e;
  --muted: #705f52;
  --line: #decfbe;
  --green: #20814a;
  --green-bg: #e9f7ee;
  --red: #b72d22;
  --red-bg: #fff0ee;
  --yellow: #9c6a00;
  --yellow-bg: #fff7dc;
  --shadow: 0 18px 50px rgba(46, 29, 17, .08);
  --radius: 18px;
  font-family: "Nunito Sans", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--cream);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 10%, rgba(241, 136, 21, .18), transparent 36%),
    linear-gradient(145deg, #f8f4ee, #eee2d3);
}

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  color: var(--brown);
  font-weight: 1000;
  line-height: .95;
  letter-spacing: .03em;
}

.brand-mark span {
  color: var(--orange);
  font-size: .68em;
  letter-spacing: .08em;
}

.login-card .brand-mark {
  font-size: 24px;
  margin-bottom: 34px;
}

h1,
h2,
h3,
h4,
.strong {
  margin-top: 0;
  font-weight: 900;
  letter-spacing: -.025em;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 44px);
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(24px, 3vw, 30px);
}

h3 {
  font-size: 21px;
}

p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid.one {
  grid-template-columns: 1fr;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

label,
.field-label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(241, 136, 21, .15);
}

input[type="checkbox"] {
  width: 22px;
  min-height: 22px;
  accent-color: var(--orange);
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--orange);
  color: #15100c;
  font-weight: 900;
  text-decoration: none;
  transition: transform .12s, background .12s, opacity .12s;
}

.btn:hover {
  background: #ff971f;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.btn.secondary {
  border-color: var(--line);
  background: var(--paper);
}

.btn.secondary:hover {
  background: var(--cream);
}

.btn.dark {
  background: var(--brown);
  color: white;
}

.btn.danger {
  border-color: #efb7b0;
  background: var(--red-bg);
  color: var(--red);
}

.btn.small {
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 13px;
}

.btn.full {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 240px;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 18px;
  background: var(--brown);
  color: white;
}

.sidebar .brand-mark {
  color: white;
  font-size: 20px;
  padding: 0 7px 26px;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #f5ede6;
  font-weight: 800;
  text-align: left;
}

.nav-link:hover,
.nav-link.active {
  background: #5c3a1c;
  color: white;
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 7px 0;
  border-top: 1px solid rgba(255, 255, 255, .13);
}

.user-chip {
  margin-bottom: 10px;
  color: #f6eee7;
  font-size: 13px;
}

.user-chip strong {
  display: block;
  font-size: 14px;
}

.main {
  min-height: 100vh;
  margin-left: 240px;
}

.mobile-head {
  display: none;
}

.mobile-nav {
  display: none;
}

.page {
  width: min(1450px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.page-head p {
  margin: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 8px 28px rgba(50, 31, 17, .035);
}

.card + .card {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-head h3,
.card-head p {
  margin-bottom: 3px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-number {
  font-size: 36px;
  font-weight: 1000;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 18px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
}

.list-row.clickable {
  cursor: pointer;
}

.list-row.clickable:hover {
  border-color: var(--orange);
}

.row-title {
  margin: 0 0 3px;
  font-weight: 900;
}

.row-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--cream-2);
  color: var(--brown-2);
  font-size: 12px;
  font-weight: 900;
}

.badge.green {
  background: var(--green-bg);
  color: var(--green);
}

.badge.red {
  background: var(--red-bg);
  color: var(--red);
}

.badge.yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.empty {
  padding: 44px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.notice {
  padding: 13px 15px;
  border: 1px solid #f1cd9c;
  border-radius: 12px;
  background: #fff7e8;
  color: #71420c;
  font-size: 14px;
}

.notice.success {
  border-color: #b6dfc4;
  background: var(--green-bg);
  color: #155f35;
}

.notice.danger {
  border-color: #efb7b0;
  background: var(--red-bg);
  color: var(--red);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  font-weight: 900;
}

.tab.active {
  border-color: var(--brown);
  background: var(--brown);
  color: white;
}

.wizard-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.wizard-step {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--muted);
  text-align: left;
  font-weight: 900;
}

.wizard-step.active {
  border-color: var(--orange);
  background: #fff3e3;
  color: var(--ink);
}

.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ingredient-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
}

.ingredient-card.done {
  border-color: #9fd0af;
  background: #f4fcf6;
}

.ingredient-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  margin: 10px 0;
  border-radius: 11px;
  background: var(--cream-2);
}

.check-row {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfa;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--cream);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

tr:last-child td {
  border-bottom: 0;
}

.search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.label-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 18px;
}

.label-preview-shell {
  min-width: 0;
  padding: 18px;
  border-radius: 16px;
  background: #d8d2cb;
}

.label-preview {
  width: 100%;
  aspect-ratio: 105 / 65;
  display: block;
  background: white;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .14);
}

.editor-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 105 / 65;
  overflow: hidden;
  background: white;
  user-select: none;
}

.editor-stage > img,
.editor-stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.editor-field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px 4px;
  border: 2px dashed var(--orange);
  background: rgba(255, 255, 255, .6);
  color: #111;
  font-size: 12px;
  font-weight: 900;
  cursor: grab;
  touch-action: none;
}

.editor-field canvas {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.editor-field.selected {
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(241, 136, 21, .2);
}

.field-list {
  display: grid;
  gap: 9px;
}

.field-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfa;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(27, 19, 13, .62);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(850px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font-weight: 1000;
}

#toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 240px;
  max-width: 420px;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--brown);
  color: white;
  box-shadow: var(--shadow);
  font-weight: 800;
  animation: toast-in .18s ease-out;
}

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

.loading {
  display: grid;
  min-height: 320px;
  place-items: center;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid var(--cream-2);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .label-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    padding-bottom: 78px;
  }

  .mobile-head {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(247, 243, 237, .95);
    backdrop-filter: blur(10px);
  }

  .mobile-head .brand-mark {
    font-size: 15px;
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid rgba(255,255,255,.1);
    background: var(--brown);
  }

  .mobile-nav .nav-link {
    min-width: 0;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 7px 2px;
    font-size: 10px;
  }

  .page {
    width: min(100% - 28px, 1450px);
    padding-top: 20px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions,
  .page-actions .btn {
    width: 100%;
  }

  .stats-grid,
  .form-grid,
  .form-grid.three,
  .form-grid.five,
  .ingredient-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .list-row {
    grid-template-columns: 1fr;
  }

  .search-line {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 26px 20px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
