@import url("https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700&display=swap");

:root {
  --color-bg: #f5f7f5;
  --color-surface: #ffffff;
  --color-primary: #2f7a4f;
  --color-primary-dark: #235c3b;
  --color-text: #1f2a24;
  --color-muted: #5b6b62;
  --color-border: #d8e0dc;
  --color-danger: #c0392b;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --color-primary-soft: #e6f0ea;
  --color-accent: #e0a43a;
  --color-accent-soft: #fbf1dd;
  --color-head: #eef4f0;
  --color-row-hover: #f2f7f4;
  --color-zebra: #f6f9f7;
  --color-ok: #2f7a4f;
  --color-ok-bg: #e3f1e8;
  --color-warn: #9a6a0e;
  --color-warn-bg: #fbefd5;
  --color-bad: #b23a2c;
  --color-bad-bg: #fbe7e4;
  --icon-accent: #e0a43a;
  --font-ui: "Golos Text", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --nav-w: 264px;
  --nav-w-collapsed: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--color-text);
  line-height: 1.5;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(47, 122, 79, 0.08), transparent 60%),
    radial-gradient(700px 450px at 100% 10%, rgba(224, 164, 58, 0.08), transparent 60%),
    radial-gradient(800px 600px at 50% 110%, rgba(47, 122, 79, 0.07), transparent 60%),
    var(--color-bg);
  background-attachment: fixed;
}

@media print {
  body {
    background: #fff;
  }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}

/* The mark: the C and the leaf as two layers on one 288×288 canvas, effects on top */
.logo__mark {
  position: relative;
  display: block;
  flex: none;
}

.logo__mark > img,
.logo__flow,
.logo__sweep {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.logo__leaf {
  transform-origin: 52% 99%;
}

.logo__wordmark {
  font-weight: 700;
  color: var(--color-primary-dark);
}

/* Menu: a soft light beam crosses the mark every 7 seconds and runs on into the letters */
.logo__sweep {
  overflow: hidden;
  -webkit-mask: url("logo.png") center / 100% 100% no-repeat;
  mask: url("logo.png") center / 100% 100% no-repeat;
}

.logo__sweep::before {
  content: "";
  position: absolute;
  top: -25%;
  bottom: -25%;
  left: 0;
  width: 42%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0));
  transform: translateX(-140%) skewX(-18deg);
  animation: logo-sweep 7s cubic-bezier(.45, 0, .35, 1) infinite;
}

@keyframes logo-sweep {
  0% { transform: translateX(-140%) skewX(-18deg); }
  17%, 100% { transform: translateX(280%) skewX(-18deg); }
}

.logo__wordmark--shine {
  background: linear-gradient(110deg, var(--color-primary-dark) 0 43%, #9ff0c4 50%, var(--color-primary-dark) 57% 100%);
  background-size: 320% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: logo-shine 7s cubic-bezier(.45, 0, .35, 1) infinite;
}

@keyframes logo-shine {
  0%, 9% { background-position: 100% 0; }
  27%, 100% { background-position: 0% 0; }
}

/* Login: the C draws itself counter-clockwise like a pen, the leaf grows from its stem, the letters rise in one by one;
   once the letters are in, logo-motion.js adds .is-shining (the beam over the letters) and runs the data pulses */
@property --logo-a {
  syntax: "<angle>";
  inherits: false;
  initial-value: 360deg;
}

.logo--large .logo__ring {
  -webkit-mask-image: conic-gradient(from 63deg at 52% 47.6%, transparent 0 calc(360deg - var(--logo-a) - 6deg), #000 calc(360deg - var(--logo-a)));
  mask-image: conic-gradient(from 63deg at 52% 47.6%, transparent 0 calc(360deg - var(--logo-a) - 6deg), #000 calc(360deg - var(--logo-a)));
}

.logo--large:not(.is-shining) .logo__ring {
  animation: logo-draw 1.1s cubic-bezier(.55, 0, .3, 1);
}

@keyframes logo-draw {
  from { --logo-a: -8deg; }
  to { --logo-a: 360deg; }
}

.logo--large:not(.is-shining) .logo__leaf {
  animation: logo-grow 0.75s cubic-bezier(.25, .8, .35, 1) 0.85s backwards, logo-sway 9s ease-in-out 1.6s infinite;
}

.logo--large.is-shining .logo__leaf {
  animation: logo-sway 9s ease-in-out infinite;
}

@keyframes logo-grow {
  0% { scale: 0; opacity: 0; }
  65% { scale: 1.08; opacity: 1; }
  100% { scale: 1; opacity: 1; }
}

/* the leaf sways now and then, pivoting on its stem */
@keyframes logo-sway {
  0%, 60%, 100% { rotate: 0deg; }
  66% { rotate: -5deg; }
  73% { rotate: 3deg; }
  80% { rotate: -1.6deg; }
  87% { rotate: 0.6deg; }
  93% { rotate: 0deg; }
}

.logo--large .logo__wordmark span {
  display: inline-block;
}

.logo--large:not(.is-shining) .logo__wordmark span {
  animation: logo-rise 0.6s cubic-bezier(.2, .9, .3, 1.2) backwards;
  animation-delay: calc(var(--i) * 55ms + 1250ms);
}

@keyframes logo-rise {
  from { opacity: 0; transform: translateY(0.45em); filter: blur(3px); }
}

.logo--large.is-shining .logo__wordmark {
  background: linear-gradient(110deg, var(--color-primary-dark) 0 43%, #9ff0c4 50%, var(--color-primary-dark) 57% 100%);
  background-size: 320% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: logo-shine 7s cubic-bezier(.45, 0, .35, 1) infinite;
}

.logo__comet {
  fill: none;
  stroke: #f4fffa;
  stroke-width: 4.5;
  stroke-linecap: round;
  opacity: 0;
}

.logo__node {
  fill: #f4fffa;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

@media (prefers-reduced-motion: reduce) {
  .logo *,
  .logo *::before {
    animation: none !important;
  }

  .logo__sweep {
    display: none;
  }
}

@media print {
  .logo__sweep,
  .logo__flow {
    display: none;
  }
}

.logo--large {
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.logo--large .logo__wordmark {
  /* close to the width of the drawing; logo-motion.js fits it exactly once the font is loaded */
  font-size: 2.15rem;
  line-height: 1.1;
  white-space: nowrap;
}

.logo--small .logo__wordmark {
  font-size: 1.1rem;
}

/* App navigation: sidebar on desktop (collapsible to icons), drawer on phones and tablets */
.ico {
  width: 20px;
  height: 20px;
  flex: none;
}

.app-topbar {
  display: none;
}

.app-nav {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  width: var(--nav-w);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.app-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1rem 0.75rem;
}

.app-nav__brand,
.app-topbar__brand {
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.app-nav__close {
  display: none;
}

.app-nav__body {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.75rem 0.75rem;
}

.app-nav__list,
.app-nav__sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 10px;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-muted);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.app-nav__link:hover {
  background: var(--color-row-hover);
  color: var(--color-text);
}

.app-nav__link.is-active,
.app-nav__toggle.has-active {
  color: var(--color-primary-dark);
}

.app-nav__link.is-active {
  background: var(--color-primary-soft);
}

.app-nav__scan {
  margin-bottom: 0.5rem;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.app-nav__scan:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

.app-topbar__scan {
  display: none;
}

.app-nav__icon {
  width: 22px;
  height: 22px;
  flex: none;
}

.app-nav__label {
  flex: 1;
  min-width: 0;
}

/* "Новые сообщения" with unread ones: the envelope pulses; the count is in the label, on the icon when collapsed */
.app-nav__link.has-unread {
  position: relative;
}

.app-nav__link.has-unread .app-nav__icon {
  color: var(--color-primary);
  animation: nav-unread 2.4s ease-in-out infinite;
}

@keyframes nav-unread {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.88); }
}

@media (prefers-reduced-motion: reduce) {
  .app-nav__link.has-unread .app-nav__icon {
    animation: none;
  }
}

.app-nav__badge {
  display: none;
}

.app-nav__chevron {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform 0.15s;
}

.app-nav__group.is-open .app-nav__chevron {
  transform: rotate(90deg);
}

.app-nav__children {
  display: grid;
  gap: 2px;
  padding: 0.15rem 0 0.5rem 2.6rem;
}

.app-nav__children[hidden] {
  display: none;
}

.app-nav__sublink {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--color-muted);
  text-decoration: none;
}

.app-nav__sublink:hover {
  background: var(--color-row-hover);
  color: var(--color-text);
}

.app-nav__sublink.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 600;
}

.app-nav__foot {
  display: grid;
  gap: 2px;
  padding: 0.5rem 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
}

.app-nav__foot form {
  margin: 0;
}

.app-nav button.app-nav__logout[type="submit"] {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: none;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.app-nav button.app-nav__logout[type="submit"]:hover {
  background: var(--color-bad-bg);
  color: var(--color-bad);
}

.app-nav a:focus-visible,
.app-nav button:focus-visible,
.app-topbar a:focus-visible,
.app-topbar button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (min-width: 1025px) {
  body:has(> .app-nav) {
    padding-left: var(--nav-w);
  }

  body:has(> .app-nav.is-collapsed) {
    padding-left: var(--nav-w-collapsed);
  }

  .app-nav {
    transition: width 0.2s;
  }

  .app-nav.is-collapsed {
    width: var(--nav-w-collapsed);
  }

  .app-nav.is-collapsed .app-nav__label,
  .app-nav.is-collapsed .app-nav__chevron,
  .app-nav.is-collapsed .app-nav__children,
  .app-nav.is-collapsed .logo__wordmark {
    display: none;
  }

  .app-nav.is-collapsed .app-nav__badge {
    display: block;
    position: absolute;
    top: 4px;
    left: 30px;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }

  .app-nav.is-collapsed .app-nav__head {
    justify-content: center;
    padding-inline: 0.5rem;
  }

  .app-nav.is-collapsed .app-nav__body,
  .app-nav.is-collapsed .app-nav__foot {
    padding-inline: 0.6rem;
  }

  .app-nav.is-collapsed .app-nav__link {
    justify-content: center;
    padding-inline: 0;
  }

  .app-nav.is-collapsed .app-nav__collapse .app-nav__icon {
    transform: rotate(180deg);
  }

  .app-nav.is-collapsed .logo__mark {
    width: 40px !important;
    height: 40px !important;
  }
}

@media (max-width: 1024px) {
  .app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 56px;
    padding: 0 12px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }

  .app-topbar__menu {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--color-text);
    cursor: pointer;
  }

  .app-topbar__menu .ico {
    width: 24px;
    height: 24px;
  }

  .app-topbar__title {
    margin-left: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted);
  }

  .app-topbar__scan {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    border: 0;
    border-radius: 10px;
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
  }

  .app-topbar__scan .ico {
    width: 24px;
    height: 24px;
  }

  .app-nav {
    width: min(300px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .app-nav.is-open {
    transform: none;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  }

  .app-nav__close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--color-muted);
    cursor: pointer;
  }

  .app-nav__collapse {
    display: none;
  }

  .app-nav__link {
    min-height: 48px;
  }

  .app-nav__sublink {
    padding: 0.7rem 0.65rem;
  }

  .app-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(20, 30, 25, 0.45);
  }

  body.nav-locked {
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .app-topbar .logo__wordmark {
    display: none;
  }
}

/* Stub page for sections that are not built yet */
.stub {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding-block: 3rem;
  text-align: center;
}

.stub h1 {
  margin: 0;
  font-size: 1.4rem;
  text-wrap: balance;
}

.stub p {
  margin: 0;
  max-width: 45ch;
}

.stub__badge {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}

.stub__icon {
  width: 36px;
  height: 36px;
}

@media (prefers-reduced-motion: reduce) {
  .app-nav,
  .app-nav__chevron {
    transition: none;
  }
}

/* Auth page (login) */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-card h1 {
  font-size: 1.25rem;
  margin: 0 0 1.5rem;
}

.auth-card form {
  text-align: left;
}

/* Forms */
form p {
  margin: 0 0 1rem;
}

label {
  display: block;
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

button[type="submit"] {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: var(--color-primary-dark);
}

/* Cards / lists */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

ul.batch-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.batch-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}

.error {
  color: var(--color-danger);
  background: #fbeceb;
  border: 1px solid #f1c3bf;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

/* Label recognition */
.label-recognition {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: #fafcfb;
}

.label-recognition__balance {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.label-recognition__balance--low {
  color: var(--color-danger);
  font-weight: 600;
}

.label-recognition__hint {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.label-recognition__pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.label-recognition__pick {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 1rem;
}

.label-recognition__pick input {
  display: none;
}

.label-recognition__pick:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.label-recognition__previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.label-recognition__preview {
  position: relative;
}

.label-recognition__preview img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.label-recognition__preview button {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--color-danger);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

.label-recognition__status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.label-recognition__status--error {
  color: var(--color-danger);
}

.button-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
}

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

textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 5.5rem;
  margin-top: 0.3rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  color: var(--color-text, inherit);
  resize: vertical;
}

select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--color-surface);
}

.form-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}

.form-group {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem 1rem 0;
  margin: 0 0 1rem;
}

.form-group legend {
  font-size: 0.9rem;
  color: var(--color-muted);
  padding: 0 0.25rem;
}

.field--uncertain input,
.field--uncertain select {
  border-color: #e0a800;
  background: #fff8e1;
}

.field--computed input,
.field--computed select {
  border-color: #3b82c4;
  background: #eef5fc;
}

.field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 640px) {
  .auth-card {
    padding: 2rem 1.25rem;
  }
}

/* Raw material batch list */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-head h1 {
  margin: 0;
}

.button-link {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  text-decoration: none;
}

.button-link:hover {
  background: var(--color-primary-dark);
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* QR scanner */
.qr-scanner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.85);
}

.qr-scanner__box {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.qr-scanner__view {
  position: relative;
}

.qr-scanner__video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: cover;
  border-radius: var(--radius);
  background: #000;
}

.qr-scanner__frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  pointer-events: none;
}

.qr-scanner__message {
  margin: 0.75rem 0;
  color: #fff;
}

.qr-scanner__close {
  background: #fff;
  color: var(--color-text);
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-form input[type="search"] {
  flex: 1 1 16rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
}

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

.table-scroll {
  overflow: auto;
  max-height: min(70vh, 760px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
}

.batch-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}

.batch-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.7rem 0.9rem;
  background: var(--color-head);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.batch-table tbody th,
.batch-table tfoot th,
.batch-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}

.batch-table td:has(> .row-link) {
  padding: 0;
}

.batch-table tbody tr:last-child > *,
.batch-table tfoot tr:last-child > * {
  border-bottom: 0;
}

.batch-table tbody tr {
  transition: background-color 0.15s;
}

.batch-table tbody tr:hover {
  background: var(--color-row-hover);
}

.batch-table tbody tr > :first-child {
  box-shadow: inset 3px 0 0 transparent;
}

.batch-table tbody tr:hover > :first-child {
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.row-link {
  display: block;
  padding: 0.75rem 0.9rem;
  color: inherit;
  text-decoration: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.pill--ok {
  color: var(--color-ok);
  background: var(--color-ok-bg);
}

.pill--warn {
  color: var(--color-warn);
  background: var(--color-warn-bg);
}

.pill--bad {
  color: var(--color-bad);
  background: var(--color-bad-bg);
}

.pill--type-main {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}

.pill--type-extra {
  color: var(--color-warn);
  background: var(--color-accent-soft);
}

.pill--type-packaging {
  color: var(--color-muted);
  background: var(--color-head);
}

.search-form__select {
  flex: 0 0 auto;
  width: auto;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--color-surface);
}

.stock {
  display: grid;
  gap: 0.3rem;
  justify-items: end;
}

.stock-bar {
  display: block;
  width: 100%;
  min-width: 80px;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--color-primary-soft);
}

.stock-bar > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--color-primary);
}

.stock-bar--low > i {
  background: var(--color-accent);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pager a,
.pager span {
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
}

.pager a {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 500;
  text-decoration: none;
}

.pager a:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.pager span {
  color: var(--color-muted);
}

@media (prefers-reduced-motion: reduce) {
  .batch-table tbody tr {
    transition: none;
  }
}

/* Raw material batch card */
.batch-details {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) 1fr;
  gap: 0.4rem 1rem;
  margin: 0 0 1rem;
}

.batch-details dt {
  color: var(--color-muted);
}

.batch-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.batch-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.batch-photos img {
  display: block;
  width: 160px;
  height: 160px;
  max-width: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

@media (max-width: 480px) {
  .batch-details {
    grid-template-columns: 1fr;
  }

  .batch-details dd {
    margin-bottom: 0.4rem;
  }
}

/* Product batch form: warning and raw material picker */
.warning {
  background: #fff8e1;
  border: 1px solid #f0d68a;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text);
  font-size: 1rem;
}

.picker {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.picker legend {
  padding: 0 0.3rem;
  font-weight: 600;
}

.picker__search {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.picker__status {
  margin: 0.4rem 0;
  font-size: 0.9rem;
}

.picker__results {
  max-height: 22rem;
  overflow-y: auto;
}

.picker__option {
  display: block;
  margin: 0;
  color: var(--color-text);
  font-size: 1rem;
  cursor: pointer;
}

.picker__item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0.3rem;
  border-bottom: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}

.picker__item input[type="checkbox"] {
  margin-top: 0.3rem;
}

.picker__selected .picker__item {
  background: #f0f5f2;
}

.picker__item--expired,
.picker__selected .picker__item--expired {
  background: #fde8ec;
}

.picker__item--expired small {
  color: var(--color-danger);
}

.picker__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.5rem;
}

.picker__filters label.checkbox {
  margin: 0;
}

.picker__taken {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  color: var(--color-primary);
  line-height: 0;
}

.picker__badge {
  color: var(--color-danger);
  font-weight: 600;
  font-size: 0.85rem;
}

.picker__remove {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  cursor: pointer;
  line-height: 1;
}

/* Raw material intake, withdrawals and QR label */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.radio-group legend {
  width: 100%;
}

.total-quantity output {
  font-weight: 600;
}

.nonconforming {
  color: #c62828;
  font-weight: 600;
}

.batch-no {
  color: var(--color-muted);
  font-weight: 600;
}

.flash {
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.flash--success {
  background: #e8f5e9;
  border-color: #a5d6a7;
}

.flash--warning {
  background: #fff8e1;
  border-color: #f0d68a;
}

.flash--error {
  background: #fdecea;
  border-color: #f5b5ae;
}

/* Several mistakes of one form submit, listed together. */
.flash p {
  margin: 0;
}

.flash__list {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.batch-label {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.label-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Dictionaries */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
}

.tabs__tab {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text);
  text-decoration: none;
}

.tabs__tab--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.dictionary-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.dictionary-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
}

.dictionary-row button[type="submit"] {
  padding: 0.6rem 0.9rem;
  white-space: nowrap;
}

button[type="submit"].button-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

button[type="submit"].button-danger {
  background: var(--color-surface);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

@media (max-width: 480px) {
  .dictionary-row {
    flex-wrap: wrap;
  }

  .dictionary-row input[type="text"] {
    flex-basis: 100%;
  }
}

/* Combobox: suggestions from a dictionary */
.combobox {
  position: relative;
}

.combobox--has-toggle input[type="text"] {
  padding-right: 2.4rem;
}

.combobox__toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 2.2rem;
  border: none;
  border-left: 1px solid var(--color-border);
  border-radius: 0 6px 6px 0;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.combobox__toggle[hidden] {
  display: none;
}

.combobox__list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 16rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.combobox__option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--color-text);
}

.combobox__option--active,
.combobox__option:hover {
  background: #e8f5e9;
}

/* Recipes: text editor, ingredient table, photos */
.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.rich-text {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
}

.rich-text__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.rich-text__toolbar button {
  min-width: 2.2rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.95rem;
}

.rich-text__colors {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.rich-text__toolbar button.rich-text__color {
  min-width: 0;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-radius: 50%;
}

.rich-text__area {
  min-height: 12rem;
  padding: 0.75rem;
  outline: none;
  overflow-wrap: anywhere;
}

.rich-text__area:focus {
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.recipe-body {
  margin: 1rem 0;
  overflow-wrap: anywhere;
}

.recipe-table th,
.recipe-table td {
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

.recipe-table thead th {
  vertical-align: top;
}

.recipe-table tbody th {
  font-weight: 600;
  white-space: normal;
}

.recipe-table th input.recipe-table__column-name {
  width: 7rem;
  font-weight: 600;
}

.recipe-table input.recipe-table__cell {
  width: 6.5rem;
}

.recipe-table input[type="text"] {
  padding: 0.35rem 0.4rem;
}

.recipe-table__tools {
  display: flex;
  gap: 0.2rem;
  margin-top: 0.25rem;
  white-space: nowrap;
}

.recipe-table__btn {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
}

.recipe-table__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.recipe-table__add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.recipe-table__add .combobox {
  flex: 1 1 16rem;
}

.recipe-table__add button {
  padding: 0.6rem 0.9rem;
}

.recipe-table__name-field {
  display: block;
  margin: 0.4rem 0;
}

.recipe-photo label.checkbox {
  margin-top: 0.25rem;
}

.recipe-photo--deleted img {
  opacity: 0.35;
}

.dictionary-row__recipe {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
}

.dictionary-archive-link {
  margin: 0.5rem 0 1rem;
}

.recipe-picker__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0;
}

.recipe-picker__chips:empty {
  margin: 0;
}

.form-group.recipe-picker {
  padding-bottom: 1rem;
}

.recipe-picker__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.3rem 0.2rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #f0f5f2;
}

.recipe-picker__chip button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 1rem;
}

/* Production plan */
.container--wide {
  max-width: 1440px;
}

.plan-filter {
  margin-bottom: 1rem;
}

.plan-table th,
.plan-table td {
  text-align: right;
  white-space: nowrap;
}

.plan-table th[scope="row"],
.plan-table thead th:first-child {
  text-align: left;
  white-space: normal;
}

.plan-table__total {
  font-weight: 600;
}

.plan-table td,
.plan-table th {
  vertical-align: middle;
}

.plan-table input.plan-cell {
  width: 5.5rem;
  text-align: right;
  padding: 0.35rem 0.5rem;
}

.plan-table input.plan-cell--error {
  border-color: var(--color-danger);
  background: #fdecea;
}

.plan-remove {
  border: none;
  background: none;
  color: var(--color-danger);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.plan-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

.plan-add .combobox {
  flex: 1 1 16rem;
}

.plan-errors {
  color: var(--color-danger);
  padding-left: 1.25rem;
}

.plan-errors:empty {
  display: none;
}

.plan-years {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}

.plan-years a {
  text-decoration: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 0.5rem;
}

.week-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.5rem;
}

.week-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.25rem;
  border: 1px solid;
  border-radius: 8px;
  text-decoration: none;
}

.week-tile__number {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.week-tile__dates {
  font-size: 0.75rem;
}

.week-tile--past {
  background: #f1f2f1;
  border-color: #e0e3e1;
  color: #9aa59f;
}

.week-tile--current {
  background: #d4f0dd;
  border: 2px solid #2f9e5a;
  color: #0f5132;
}

.week-tile--current .week-tile__number {
  font-size: 1.6rem;
}

.week-tile--future {
  background: #e3f1fd;
  border-color: #2b6cb0;
  color: #1e3a8a;
}

.week-tile--selected {
  box-shadow: 0 0 0 3px var(--color-text);
}

.week-tile__mark {
  position: absolute;
  top: 0.15rem;
  right: 0.35rem;
  font-size: 0.6rem;
}

/* Recipe block on the product batch form, ingredient needs on the raw material card */
.recipe-info {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  background: #f8faf9;
}

.recipe-info h3 {
  margin-top: 0;
}

.plan-needs {
  margin-top: 0.75rem;
}

/* Batch list filters */
.search-form--dates {
  align-items: flex-start;
}

.date-range {
  display: inline-flex;
  flex-direction: column;
  gap: 0.4rem;
}

.date-range__inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.6rem;
}

.date-range label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 1rem;
}

.date-range input[type="date"] {
  padding: 0.5rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
}

.button-secondary--link {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  text-decoration: none;
}

.batch-table small.sub {
  color: var(--color-muted);
  white-space: nowrap;
}

.batch-table .nowrap {
  white-space: nowrap;
}

.batch-table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.period-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.period-presets[hidden] {
  display: none;
}

.period-presets button {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.period-presets button:hover,
.period-presets button.is-active {
  border-color: var(--color-primary);
}

.period-presets button.is-active {
  background: var(--color-primary);
  color: #fff;
}

/* Dense numeric grids: production plan, needs, recipes */
.plan-table,
.recipe-table {
  font-size: 0.9rem;
}

.plan-table tbody th,
.plan-table tfoot th,
.plan-table td,
.recipe-table tbody th,
.recipe-table td {
  padding: 0.5rem 0.75rem;
}

.plan-table tr > * + *,
.recipe-table tr > * + * {
  border-left: 1px solid var(--color-border);
}

.plan-table tr > :first-child,
.recipe-table tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--color-surface);
}

.plan-table thead tr > :first-child,
.recipe-table thead tr > :first-child {
  z-index: 3;
  background: var(--color-head);
}

.plan-table tbody tr:nth-child(even) > *,
.recipe-table tbody tr:nth-child(even) > * {
  background: var(--color-zebra);
}

.plan-table tbody tr:hover > *,
.recipe-table tbody tr:hover > * {
  background: var(--color-row-hover);
}

.plan-table tfoot tr > *,
.plan-table tfoot tr > :first-child {
  background: var(--color-head);
  border-top: 1px solid var(--color-border);
  font-weight: 700;
}

.plan-table tbody tr:nth-child(n) > .plan-table__total {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.plan-table tfoot tr > .plan-table__total {
  color: var(--color-primary-dark);
}

.plan-table thead th.plan-table__today {
  color: var(--color-primary-dark);
  box-shadow: inset 0 -2px 0 var(--color-primary);
}

.plan-table tbody tr:nth-child(n) > td.plan-table__today {
  background: rgba(47, 122, 79, 0.06);
}

.plan-value[data-value="0"] {
  color: var(--color-muted);
  opacity: 0.5;
}

/* Lists on phones: "Table | Cards" switch, cards built from the same table rows */
.view-toggle {
  display: none;
}

@media (max-width: 720px) {
  .view-toggle {
    display: inline-flex;
    margin: 0 0 0.75rem;
    padding: 3px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-head);
  }

  .view-toggle__btn {
    min-height: 40px;
    padding: 0 1rem;
    border: 0;
    border-radius: 8px;
    background: none;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-muted);
    cursor: pointer;
  }

  .view-toggle__btn[aria-pressed="true"] {
    background: var(--color-surface);
    color: var(--color-primary-dark);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .table-scroll {
    max-height: none;
  }

  /* Table mode: the name column stays while the rest scrolls sideways */
  .batch-table td.card-title {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--color-surface);
    box-shadow: 1px 0 0 var(--color-border);
  }

  .batch-table thead th.card-title {
    left: 0;
    z-index: 3;
    box-shadow: 1px 0 0 var(--color-border);
  }

  /* Cards mode */
  .table-scroll:has(> .batch-table--cards) {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .batch-table--cards,
  .batch-table--cards tbody {
    display: block;
  }

  .batch-table--cards thead {
    display: none;
  }

  .batch-table--cards tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface);
  }

  .batch-table--cards tbody tr:hover > :first-child {
    box-shadow: none;
  }

  .batch-table--cards td,
  .batch-table--cards td:has(> .row-link) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0;
    border: 0;
    font-size: 0.85rem;
    text-align: left;
  }

  .batch-table--cards td::before {
    content: attr(data-label);
    color: var(--color-muted);
  }

  .batch-table--cards td[data-empty] {
    display: none;
  }

  .batch-table--cards .row-link {
    padding: 0;
  }

  .batch-table--cards .stock {
    justify-items: start;
  }

  .batch-table--cards td.card-title,
  .batch-table--cards td.card-badge {
    display: block;
    grid-row: 1;
    position: static;
    box-shadow: none;
    background: none;
  }

  .batch-table--cards td.card-title {
    grid-column: 1;
    font-size: 1rem;
    font-weight: 600;
  }

  .batch-table--cards td.card-badge {
    grid-column: 2;
    align-self: start;
  }

  .batch-table--cards td.card-title::before,
  .batch-table--cards td.card-badge::before {
    content: none;
  }

  /* The whole card opens the batch */
  .batch-table--cards td.card-title .row-link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
  }

  /* Bigger buttons for the shop floor */
  .button-link,
  .button-secondary,
  button[type="submit"] {
    min-height: 48px;
  }

  .page-head__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .page-head__actions > * {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    line-height: 1.25;
    text-align: center;
  }

  .page-head__actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

/* Names wrap into a narrow column otherwise, as the long lists scroll sideways anyway */
@media (min-width: 721px) {
  .batch-table td.card-title {
    min-width: 11rem;
  }
}

.plan-needs-panel {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.plan-needs-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.plan-needs-panel h3 {
  margin: 1rem 0 0.25rem;
  font-size: 1rem;
}

/* Employees */
.employee-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.employee-filter select {
  width: auto;
  min-width: 12rem;
}

.nfc-status:empty {
  display: none;
}

/* Journals */
.batch-table tbody tr.is-deviation > *,
.batch-table tbody tr.is-overdue > * {
  background: var(--color-bad-bg);
}

.journal-date-row th {
  padding: 0.5rem 0.75rem;
  background: var(--color-head);
  text-align: left;
  font-weight: 600;
}

.cell--warn {
  color: var(--color-warn);
  font-weight: 600;
}

.hint {
  position: relative;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

/* The full wording on hover, and on a tap on phones: the element is focusable. */
.hint:hover::after,
.hint:focus::after {
  content: attr(data-hint);
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: 16rem;
  margin-top: 0.3rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--color-text);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

@media (max-width: 720px) {
  .batch-table--cards tbody tr.is-deviation,
  .batch-table--cards tbody tr.is-overdue {
    border-color: var(--color-bad);
    background: var(--color-bad-bg);
  }

  .batch-table--cards tbody tr.journal-date-row {
    display: block;
    padding: 0.3rem 0;
    border: 0;
    background: none;
  }

  .batch-table--cards tbody tr.journal-date-row th {
    display: block;
    padding: 0;
    background: none;
  }
}

.journal-field {
  margin-bottom: 1rem;
}

.journal-field.has-error input,
.journal-field.has-error select,
.journal-field.has-error textarea {
  border-color: var(--color-danger);
}

.field-error {
  margin: 0.3rem 0 0;
  color: var(--color-danger);
  font-size: 0.85rem;
}

.journal-field__computed {
  display: inline-block;
  margin-top: 0.3rem;
  font-weight: 600;
}

.health-day__counter {
  font-size: 1.1rem;
  font-weight: 600;
}

.health-day__sign {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-primary-soft);
}

.health-day__sign .nfc-status {
  flex: 1 1 100%;
  margin: 0;
}

/* A check's label inside its cell is for the card view of phones, where the table header is hidden. */
.health-day__card-label {
  display: none;
}

@media (max-width: 720px) {
  .batch-table--cards td.health-day__check::before {
    content: none;
  }

  .health-day__card-label {
    display: block;
    color: var(--color-muted);
  }
}

/* Unload page of two-step journals */
.close-all {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.close-entry {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.close-entry.is-overdue {
  border-color: var(--color-bad);
  background: var(--color-bad-bg);
}

.close-entry.has-error {
  border-color: var(--color-danger);
}

.close-entry__pick {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--color-text);
  font-size: 1rem;
}

.close-entry__pick input {
  margin-top: 0.3rem;
}

.close-entry__fields {
  margin-top: 0.75rem;
  padding-left: 1.6rem;
}

/* Entries still in a freezer or an oven, on the unit's page */
.open-entries {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.open-entries li {
  margin-bottom: 0.35rem;
}

.open-entries li.is-overdue {
  color: var(--color-bad);
  font-weight: 600;
}

/* Main page: unloads not marked in time */
.overdue-block {
  border-left: 4px solid var(--color-bad);
  background: var(--color-bad-bg);
}

.overdue-list {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.overdue-list li {
  margin-bottom: 0.35rem;
}

.overdue-list a {
  color: var(--color-bad);
  font-weight: 600;
}

/* An additional role in the "Доступ в NeoCerta" block: checkbox, "до" date and the expiry mark in one row. */
.access-extra-role {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

/* The checkboxes of the "Доступ в NeoCerta" block are tapped on phones: a bigger box and a finger-sized row. */
.access-block label.checkbox {
  min-height: 2.75rem;
  cursor: pointer;
}

.access-block label.checkbox input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
}

/* Glass journal objects: "Изменить" and the archive button side by side, wrapping on phones */
.fragile-actions {
  white-space: nowrap;
}

.fragile-actions form {
  display: inline-block;
  margin-left: 0.75rem;
}

.fragile-actions .button-secondary {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  /* in the card view every cell is a "label | value" grid; the buttons need the whole row */
  .batch-table--cards td.fragile-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    white-space: normal;
  }

  .batch-table--cards td.fragile-actions::before {
    display: none;
  }

  .fragile-actions form {
    margin-left: 0;
  }
}

/* Glass journal: the day form — one card per object, big ✔ / ✖ for a finger */
.glass-day__group {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}

.glass-object {
  margin: 0 0 0.75rem;
  padding: 0.5rem 1rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.glass-object.is-damaged {
  border-color: var(--color-bad);
  background: var(--color-bad-bg);
}

.glass-object__name {
  padding: 0 0.3rem;
  font-weight: 600;
}

.glass-object__details {
  margin: 0 0 0.6rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.glass-object__choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.glass-choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 3rem;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  margin: 0;
  color: var(--color-text);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.glass-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.glass-choice--ok.is-checked,
.glass-choice--ok:has(input:checked) {
  border-color: var(--color-ok);
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.glass-choice--damaged.is-checked,
.glass-choice--damaged:has(input:checked) {
  border-color: var(--color-bad);
  background: var(--color-bad-bg);
  color: var(--color-bad);
}

.glass-choice:has(input:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.glass-object__comment {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.glass-object__comment[hidden] {
  display: none;
}

.glass-object__comment textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
}

.glass-object__saved {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
}

.glass-object__history {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.glass-object__history ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.glass-day__save {
  width: 100%;
  min-height: 3rem;
  margin-top: 0.5rem;
  font-size: 1.1rem;
}

@media (min-width: 721px) {
  .glass-day__save {
    width: auto;
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

/* Glass journal: the month table — objects × days, the object column stays while the days scroll */
.glass-month__switch {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.glass-month__switch a,
.glass-month__off {
  padding: 0.25rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  text-decoration: none;
}

.glass-month__off {
  color: var(--color-border);
}

.glass-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.glass-legend__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 4px;
  font-weight: 700;
}

/* .batch-table.glass-table — to win over the general .batch-table rules (sticky header, paddings, left alignment) */
.batch-table.glass-table {
  width: auto;
}

.batch-table.glass-table thead th {
  padding: 0.5rem 0.3rem;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.8rem;
}

.batch-table.glass-table td,
.batch-table.glass-table tbody th {
  padding: 0.35rem 0.3rem;
}

/* the object column stays in place while the days scroll sideways */
.batch-table.glass-table .glass-table__object {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 10rem;
  max-width: 15rem;
  padding: 0.45rem 0.75rem;
  background: var(--color-surface);
  box-shadow: inset -1px 0 0 var(--color-border);
  text-align: left;
  white-space: normal;
  font-weight: 600;
}

/* the top left corner stays above both the sticky header and the sticky column */
.batch-table.glass-table thead .glass-table__object {
  z-index: 3;
  background: var(--color-head);
}

.batch-table.glass-table .glass-table__group .glass-table__object,
.batch-table.glass-table .glass-table__group td {
  background: var(--color-head);
  color: var(--color-muted);
  font-size: 0.8rem;
}

.glass-table__details {
  display: block;
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.glass-table__day a {
  display: block;
  color: var(--color-primary);
  font-weight: 700;
}

.batch-table.glass-table td.glass-cell {
  min-width: 1.9rem;
  text-align: center;
  font-weight: 700;
}

.glass-cell--ok {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.glass-cell--damaged {
  background: var(--color-bad-bg);
  color: var(--color-bad);
}

.glass-cell--missing {
  background: #e3e7e5;
}

.batch-table.glass-table .is-today {
  box-shadow: inset 2px 0 0 var(--color-accent), inset -2px 0 0 var(--color-accent);
}

.batch-table.glass-table thead .is-today {
  background: var(--color-accent-soft);
}

.glass-damages {
  margin: 0;
  padding-left: 1.2rem;
}

.glass-damages li {
  margin-bottom: 0.6rem;
}

.glass-damages__comment {
  white-space: pre-line;
}

/* Main page: the glass journal is not filled in today — a warning, not an alarm */
.glass-reminder {
  border-left: 4px solid var(--color-accent);
  background: var(--color-warn-bg);
}

.glass-reminder h2 {
  margin-top: 0;
}

.glass-reminder p {
  margin-bottom: 0;
}

/* The comment of a ✖ in the second half of the month opens to the left, inside the scrolled table. */
.glass-table .hint.glass-hint--end::after {
  left: auto;
  right: 0;
}

/* Disinfectants: the working concentration next to the name */
.dictionary-row__norm { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
.dictionary-row__norm input { width: 4.5rem; }

/* Photos of journal entries */
.entry-photo { display: flex; flex-direction: column; gap: .25rem; }
figure.entry-photo { margin: 0; }
.entry-photo img { width: 120px; height: 120px; object-fit: cover; border-radius: 6px; }
.entry-photo--deleted img { opacity: .35; }
.entry-gallery { display: flex; flex-wrap: wrap; gap: .5rem; }
.entry-gallery img { width: 160px; height: 160px; object-fit: cover; border-radius: 6px; }
.photo-count { white-space: nowrap; }

/* Month table of a disinfection mat */
.month-switch { display: flex; align-items: center; gap: 1rem; margin: 0.75rem 0; font-size: 1.1rem; }
.month-switch a { text-decoration: none; padding: 0.25rem 0.5rem; }
.month-table tr[data-day-toggle] { cursor: pointer; }
.month-table tr[data-day-toggle]:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.month-table__today td { font-weight: 600; }
.month-table__details td { background: var(--color-head); }
.month-table__refills { margin: 0; padding-left: 1.25rem; }
.month-table__refills li { padding: 0.2rem 0; }
.month-table__refills li.is-deviation { color: var(--color-danger); }

/* Journals page: a tile per journal in its own colour (--c) and tint (--t) */
.journal-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 28rem;
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-muted);
}

.journal-search:focus-within {
  border-color: var(--color-primary);
}

.journal-search .ico {
  flex: none;
  width: 18px;
  height: 18px;
}

.journal-search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--color-text);
}

.journal-tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

@media (min-width: 700px) {
  .journal-tiles {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
}

/* at most five tiles in a row on wide screens */
@media (min-width: 1200px) {
  .journal-tiles {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.journal-tiles li[hidden] {
  display: none;
}

.journal-tile {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  height: 100%;
  min-height: 7.5rem;
  padding: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--c) 25%, white);
  border-radius: 14px;
  background: var(--t);
  color: var(--color-text);
  text-decoration: none;
  transition: box-shadow 0.15s, transform 0.15s;
}

.journal-tile:hover {
  box-shadow: 0 6px 18px -8px var(--c);
  transform: translateY(-1px);
}

.journal-tile:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}

/* the text goes over the big number */
.journal-tile > :not(.journal-tile__number) {
  position: relative;
  z-index: 1;
}

.journal-tile__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #fff;
  color: var(--c);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.journal-tile__icon {
  --icon-accent: var(--c);
  width: 22px;
  height: 22px;
}

.journal-tile__name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}

.journal-tile__status {
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--color-muted);
}

.journal-tile__status.is-alert {
  color: var(--color-danger);
  font-weight: 600;
}

.journal-tile__number {
  position: absolute;
  right: 0.4rem;
  bottom: -0.75rem;
  font-size: 3.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--c);
  opacity: 0.22;
  pointer-events: none;
}

.journal-tile--stub {
  filter: grayscale(0.85);
  opacity: 0.55;
}

.journal-tile--create {
  --c: var(--color-muted);
  --t: transparent;
  border: 1.5px dashed var(--color-border);
}

/* Settings */
.settings-block {
  margin-bottom: 1.25rem;
}

.settings-weekdays,
.settings-days-off,
.schedule-row__days {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
}

.settings-today {
  margin: 0.75rem 0 1rem;
}

.settings-days-off input[type="date"] {
  width: auto;
}

.settings-days-off__list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.settings-days-off__list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border);
}

.schedule-row {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--c) 25%, white);
  border-radius: 12px;
  background: var(--t);
}

.schedule-row legend {
  padding: 0 0.35rem;
  font-weight: 600;
}

.schedule-row__number {
  color: var(--c);
  font-weight: 800;
}

.schedule-row.has-error input[type="text"] {
  border-color: var(--color-danger);
}

/* own days are shown only when "свои" is chosen */
.schedule-row__days:not(:has(input[type="radio"][value="1"]:checked)) .schedule-row__day {
  display: none;
}

.missed-block h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.95rem;
}

.missed-block__mark {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--c);
  vertical-align: 0.05rem;
}

.journal-schedule { margin: -0.25rem 0 1rem; font-size: 0.9rem; }

/* Photo page of journal entries */
.photo-targets { margin: .5rem 0 1rem; padding-left: 1.2rem; }
.photo-actions { margin-top: 1.25rem; }
.entry-photo form { margin: 0; }
[data-journal-photos] { margin-top: 1rem; }
#photos { scroll-margin-top: 5rem; }

/* Settings: who gets notifications */
.notify-table { width: 100%; border-collapse: collapse; }
.notify-table th, .notify-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--color-border); vertical-align: top; text-align: left; }
.notify-table tbody th { font-weight: 500; min-width: 12rem; }
.positions-picker summary { cursor: pointer; list-style: none; }
.positions-picker summary::-webkit-details-marker { display: none; }
.positions-picker summary::after { content: " ▾"; color: #8a94a0; }
.positions-picker__list { display: grid; gap: .15rem; margin-top: .35rem; max-height: 16rem; overflow-y: auto; }
.quiet-hours { border: 0; padding: 0; margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.quiet-hours input[type=text] { width: 4.5rem; }
.quiet-hours .muted { flex-basis: 100%; margin: 0; }
/* Notifications and the app */
.push-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.push-primary { background: var(--color-primary); color: #fff; border: none; border-radius: 6px; padding: 0.65rem 1.5rem; font-size: 1rem; cursor: pointer; }
.push-primary:hover { background: var(--color-primary-dark); }

/* Main page: install the app */
.install-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.install-banner[hidden] { display: none; }
.install-banner p { margin: 0; }
.install-banner__actions { display: flex; align-items: center; gap: .75rem; }
.install-banner__close { background: none; border: 0; font-size: 1.5rem; line-height: 1; color: #8a94a0; cursor: pointer; padding: 0 .25rem; }

/* Unread count in a tab of Новые сообщения (the tabs themselves are the pills from Dictionaries) */
.tabs__count {
  color: var(--color-danger);
  font-weight: 700;
}

.tabs__tab--active .tabs__count {
  color: inherit;
}

.message-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.message-list > .card {
  margin-bottom: 0;
}

.message--new {
  border-left: 4px solid var(--color-primary);
  background: var(--color-primary-soft);
}

.message__meta {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0 0 0.25rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.message__new {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.message__title {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}

.message__body {
  max-width: 75ch;
  line-height: 1.55;
}

/* Задать вопрос в техподдержку */
.support-form {
  max-width: 640px;
}

.support-form label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.support-form input,
.support-form textarea {
  width: 100%;
}

.support-form__contacts {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
