:root {
  --fresh-ink: #0d2a45;
  --fresh-muted: #587087;
  --fresh-line: #dbe4e8;
  --fresh-accent: #087f7b;
  --fresh-accent-dark: #066662;
  --fresh-accent-soft: #eaf7f6;
  --fresh-danger: #9f2929;
  --fresh-warning: #855b0a;
  --fresh-success: #17643f;
  --fresh-shadow: 0 14px 34px rgba(15,42,69,.07);
  --sticky-row-width: 30px;
  --sticky-sku-width: 190px;
}

.hidden { display: none !important; }

.freshness-content {
  width: min(calc(100% - 56px), var(--home-content-max));
  margin: 0 auto;
  padding-bottom: 96px;
}

.freshness-route-head { padding-bottom: 20px; }

.safe-back-button,
.btn-primary,
.btn-secondary {
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.safe-back-button {
  min-height: 34px;
  margin-bottom: 14px;
  border: 1px solid var(--fresh-line);
  background: #fff;
  color: var(--fresh-ink);
}

.freshness-loading,
.freshness-state,
.freshness-panel {
  border: 1px solid var(--fresh-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--fresh-shadow);
}

.freshness-loading,
.freshness-state {
  min-height: 88px;
  display: flex;
  align-items: center;
  padding: 22px 30px;
  color: var(--fresh-muted);
  font-size: 13px;
}

.freshness-state {
  display: block;
  max-width: 620px;
}

.freshness-state h2 { margin: 0 0 8px; color: var(--fresh-ink); }
.freshness-state p { color: var(--fresh-muted); font-size: 11px; }
.freshness-state a { color: var(--fresh-accent); font-size: 10px; font-weight: 800; }

.freshness-panel { padding: 22px; }

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

.freshness-panel-head h2 {
  margin: 0;
  color: var(--fresh-ink);
  font-size: 20px;
}

.freshness-panel-head p {
  margin: 5px 0 0;
  color: var(--fresh-muted);
  font-size: 11px;
}

.freshness-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--fresh-accent);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.freshness-filter-grid {
  display: grid;
  grid-template-columns: 170px minmax(300px, 1.5fr) minmax(220px, .8fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--fresh-line);
  border-radius: 12px;
  background: #f9fbfb;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  color: var(--fresh-muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--fresh-line);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--fresh-ink);
  font: inherit;
  font-size: 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(8,127,123,.5);
  box-shadow: 0 0 0 3px rgba(8,127,123,.09);
}

.store-search-wrap { position: relative; }

.store-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--fresh-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(13,42,69,.15);
}

.store-search-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid #edf1f3;
  cursor: pointer;
}

.store-search-item:hover,
.store-search-item.active { background: var(--fresh-accent-soft); }
.store-search-item.disabled { opacity: .55; pointer-events: none; }
.store-search-name { color: var(--fresh-ink); font-size: 10px; font-weight: 800; }
.store-search-meta { margin-top: 3px; color: var(--fresh-muted); font-size: 9px; }
.store-state-badge { color: var(--fresh-accent); font-size: 8px; font-weight: 800; }

.selected-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.selected-chip {
  padding: 5px 8px;
  border: 1px solid #cbd8df;
  border-radius: 999px;
  background: #fff;
  color: var(--fresh-ink);
  font-size: 9px;
  font-weight: 750;
}

.principal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 44px;
  align-items: center;
}

.principal-tab {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--fresh-line);
  border-radius: 8px;
  background: #fff;
  color: var(--fresh-ink);
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
}

.principal-tab.active {
  border-color: var(--fresh-accent);
  background: var(--fresh-accent);
  color: #fff;
}

.principal-tab.completed { opacity: .68; }

.freshness-status-row {
  margin-top: 14px;
  padding: 0 2px;
}

.muted { color: var(--fresh-muted); font-size: 10px; line-height: 1.5; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 850;
  white-space: nowrap;
}

.pill-success { background: #eaf8f1; color: var(--fresh-success); }
.pill-warning { background: #fff6df; color: var(--fresh-warning); }

.freshness-inline-loading {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--fresh-line);
  border-radius: 11px;
  background: #f9fbfb;
}

.freshness-inline-loading span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fresh-accent);
  animation: freshPulse 1s infinite alternate;
}

.freshness-inline-loading p {
  margin: 0;
  color: var(--fresh-muted);
  font-size: 11px;
}

@keyframes freshPulse { to { opacity: .25; transform: scale(.72); } }

.quality-panel,
.empty-state {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  font-size: 10px;
  line-height: 1.5;
}

.quality-title {
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.quality-panel ul { margin: 0; padding-left: 18px; }
.quality-danger { border: 1px solid #efc4c4; background: #fff5f5; color: var(--fresh-danger); }
.quality-warning { border: 1px solid #ead6a4; background: #fff8e8; color: var(--fresh-warning); }
.empty-state { border: 1px solid var(--fresh-line); background: #f7f9fa; color: var(--fresh-muted); }

.swipe-hint {
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid #cfe1ec;
  border-radius: 9px;
  background: #f4f9fc;
  color: #476579;
  font-size: 9px;
}

.table-wrap {
  width: 100%;
  max-height: calc(100vh - 300px);
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--fresh-line);
  border-radius: 11px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 990px;
  border-collapse: collapse;
}

th,
td {
  padding: 8px;
  border-right: 1px solid #edf1f3;
  border-bottom: 1px solid #edf1f3;
  color: var(--fresh-ink);
  font-size: 9px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f5f8f9;
  color: #36536a;
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 4;
  width: var(--sticky-row-width);
  min-width: var(--sticky-row-width);
  background: #fff;
}

.sticky-col-2 {
  position: sticky;
  left: var(--sticky-row-width);
  z-index: 4;
  width: var(--sticky-sku-width);
  min-width: var(--sticky-sku-width);
  background: #fff;
}

thead .sticky-col,
thead .sticky-col-2 {
  z-index: 7;
  background: #f5f8f9;
}

.sku-cell {
  font-weight: 800;
  line-height: 1.35;
  white-space: normal;
}

.uom-col {
  width: 45px;
  min-width: 45px;
  text-align: center;
}

.th-section-expired { background: #fff4f4; color: var(--fresh-danger); }
.th-section-nearex { background: #fff8e8; color: var(--fresh-warning); }
.th-section-remarks { background: #f5f8f9; }

td.expired-section { background: #fffafa; }
td.nearex-section { background: #fffdf7; }

.num-input {
  width: 58px;
  min-width: 58px;
  padding-inline: 6px;
  text-align: center;
  font-weight: 800;
}

.date-input {
  width: 118px;
  min-width: 118px;
  padding-inline: 7px;
}

.select-input {
  width: 140px;
  min-width: 140px;
  padding-inline: 8px;
}

.remarks-text {
  width: 130px;
  min-width: 130px;
  min-height: 40px;
}

.readonly-row input,
.readonly-row select,
.readonly-row textarea {
  background: #f3f5f6;
  color: #6d7f8f;
  cursor: not-allowed;
}

.summary-box {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--fresh-line);
  border-radius: 12px;
  background: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 10px;
}

.summary-item {
  min-height: 76px;
  padding: 13px;
  border: 1px solid var(--fresh-line);
  border-radius: 10px;
  background: #f8fafb;
}

.summary-item .label {
  color: var(--fresh-muted);
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
}

.summary-item .value {
  margin-top: 7px;
  color: var(--fresh-ink);
  font-size: 20px;
  font-weight: 850;
}

.value-danger { color: var(--fresh-danger) !important; }
.value-warning { color: var(--fresh-warning) !important; }
.value-success { color: var(--fresh-success) !important; }

.summary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn-primary {
  border: 1px solid var(--fresh-accent);
  background: var(--fresh-accent);
  color: #fff;
}

.btn-secondary {
  border: 1px solid var(--fresh-line);
  background: #fff;
  color: var(--fresh-ink);
}

.btn-danger {
  border-color: #efc4c4;
  background: #fff5f5;
  color: var(--fresh-danger);
}

#stickySubmitBar {
  position: fixed;
  left: var(--home-sidebar-width, 248px);
  right: 0;
  bottom: 0;
  z-index: 70;
  display: none;
  padding: 9px 18px;
  border-top: 1px solid var(--fresh-line);
  background: rgba(255,255,255,.98);
  box-shadow: 0 -8px 24px rgba(15,42,69,.08);
}

#stickySubmitBar.show { display: block; }

.sticky-bar-inner {
  width: min(100%, var(--home-content-max));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.sticky-bar-stats,
.sticky-bar-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.sticky-stat {
  padding: 5px 8px;
  border: 1px solid var(--fresh-line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--fresh-ink);
  font-size: 8px;
  font-weight: 750;
}

.sticky-stat.expired { background: #fff5f5; color: var(--fresh-danger); }
.sticky-stat.nearex { background: #fff8e8; color: var(--fresh-warning); }
.sticky-stat.clean { background: #eaf8f1; color: var(--fresh-success); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 78px;
  z-index: 200;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--fresh-ink);
  color: #fff;
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .18s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 899px) {
  .freshness-content {
    width: min(calc(100% - 20px), var(--home-content-max));
    padding-bottom: 150px;
  }

  .freshness-filter-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }

  #stickySubmitBar {
    left: 0;
    bottom: 66px;
  }
}

@media (max-width: 760px) {
  :root {
    --sticky-row-width: 26px;
    --sticky-sku-width: 128px;
  }

  .freshness-content { width: calc(100% - 12px); }
  .freshness-panel { padding: 14px; border-radius: 13px; }
  .freshness-panel-head { flex-direction: column; gap: 9px; }
  .freshness-filter-grid { grid-template-columns: 1fr; padding: 12px; }
  .principal-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .principal-tab { flex: 0 0 auto; }
  .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .summary-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .summary-actions button:last-child { grid-column: 1 / -1; }

  .table-wrap {
    max-height: calc(100vh - 230px);
  }

  table {
    min-width: 920px;
  }

  .sticky-bar-inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .sticky-bar-stats {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
  }

  .sticky-stat {
    display: grid;
    place-items: center;
    text-align: center;
  }

  .sticky-bar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .sticky-bar-actions button { width: 100%; }
}

@media (max-width: 390px) {
  .date-input { width: 108px; min-width: 108px; }
  .select-input { width: 126px; min-width: 126px; }
  .remarks-text { width: 116px; min-width: 116px; }
}