:root {
  --bg-a: #f4fbf3;
  --bg-b: #dff1dd;
  --ink: #1f3427;
  --ink-soft: #4f6a58;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: #cfe6cf;
  --line: #b9d5bd;
  --green-900: #20472f;
  --green-700: #2f6a43;
  --green-600: #3f8b53;
  --green-500: #58a868;
  --green-400: #7ac183;
  --card-head-a: #b9ea85;
  --card-head-b: #9bd46f;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Avenir Next", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0;
  color: var(--ink);
  padding-bottom: 20px;
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 255, 255, 0.7), transparent 30%),
    radial-gradient(circle at 84% 12%, rgba(123, 184, 120, 0.22), transparent 30%),
    repeating-linear-gradient(
      -22deg,
      rgba(114, 174, 109, 0.05) 0,
      rgba(114, 174, 109, 0.05) 12px,
      transparent 12px,
      transparent 28px
    ),
    linear-gradient(180deg, var(--bg-a), var(--bg-b));
}

body.modal-open {
  overflow: hidden;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
}

.hero {
  min-height: 110px;
  border-radius: 12px;
  margin-bottom: 18px;
  background:
    radial-gradient(circle at 92% 22%, rgba(178, 230, 141, 0.32), transparent 30%),
    linear-gradient(110deg, #234f33 0%, #2f7244 48%, #4ea860 100%);
  color: #f7fffa;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 28px rgba(28, 74, 43, 0.22);
}

.hero h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.6px;
  line-height: 1.1;
  font-weight: 800;
}

.hero-times {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.hero-times span {
  font-size: 12px;
  color: #e8ffe8;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.08);
}

.hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.session-info {
  margin: 0;
  font-size: 13px;
  color: #f1fff2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 22px rgba(39, 92, 53, 0.08);
  margin-bottom: 16px;
  backdrop-filter: blur(3px);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.category-filter {
  display: flex;
  flex-direction: column;
  min-width: 170px;
}

.toolbar label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

.toolbar select,
.toolbar input,
.toolbar button {
  height: 44px;
  min-height: 44px;
  box-sizing: border-box;
  font-size: 16px;
  line-height: 1.2;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.toolbar select,
.toolbar input {
  color: var(--ink);
  background: #f9fff8;
}

.toolbar select:focus,
.toolbar input:focus {
  outline: 2px solid rgba(93, 171, 105, 0.22);
  border-color: var(--green-500);
}

.toolbar input[type="text"] {
  flex: 1;
  min-width: 320px;
}

.toolbar button {
  border: none;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
  white-space: nowrap;
  min-width: 120px;
  color: #fff;
}

.toolbar button:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.search-btn {
  background: linear-gradient(180deg, var(--green-600), var(--green-700));
}

.filter-btn {
  background: linear-gradient(180deg, #3c5f4a, #2f4f3c);
}

.sort-btn.active {
  background: linear-gradient(180deg, #76bd7e, #589a61);
  box-shadow: 0 0 0 2px rgba(114, 182, 120, 0.3) inset;
}

.meta {
  margin: 2px 0 12px;
  color: var(--ink-soft);
  font-size: 14px;
}

.meta p {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.card {
  background: linear-gradient(180deg, #f5fff3 0%, #ecf9e9 100%);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #b9d7b8;
  box-shadow: 0 10px 24px rgba(32, 83, 46, 0.12);
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card.card-low-stock {
  border-color: #de4b4b;
  box-shadow: 0 10px 24px rgba(185, 40, 40, 0.22);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(30, 78, 43, 0.16);
}

.card-head {
  background:
    radial-gradient(circle at 96% 18%, rgba(255, 255, 255, 0.46), transparent 28%),
    linear-gradient(180deg, #c6ef9e, #aede80);
  border-bottom: 1px solid rgba(40, 84, 46, 0.22);
}

.head-row {
  padding: 10px 12px;
}

.row-name {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  border-bottom: 1px solid rgba(40, 84, 46, 0.22);
  min-height: 64px;
}

.en-name {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.15px;
  color: #1f3a28;
  word-break: break-word;
}

.name-sub {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cn-name,
.sku-inline {
  font-size: 12px;
  color: #2f5a3b;
  text-align: left;
  line-height: 1.35;
  word-break: break-word;
}

.cn-name {
  max-width: 68%;
}

.sku-inline {
  text-align: right;
  max-width: 32%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-composition {
  color: #1f3a28;
  font-size: 13px;
  line-height: 1.45;
  min-height: 58px;
  padding-top: 9px;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.composition-line {
  display: block;
}

.card-foot {
  background: linear-gradient(180deg, #f6fff4 0%, #e9f8e6 100%);
  padding: 10px;
  min-height: 216px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
}

.card-image-wrap {
  flex: 1;
  min-height: 172px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-foot img {
  width: 100%;
  max-height: 176px;
  height: auto;
  object-fit: contain;
  background: #f9fff7;
  border-radius: 8px;
  border: 1px solid #c6dec7;
  box-shadow: 0 4px 12px rgba(27, 70, 40, 0.1);
}

.previewable-image {
  cursor: zoom-in;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.previewable-image:hover {
  transform: scale(1.01);
  box-shadow: 0 6px 14px rgba(27, 70, 40, 0.15);
}

.no-image {
  width: 100%;
  min-height: 160px;
  border-radius: 8px;
  border: 1px dashed #95bf99;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5f7f65;
  font-size: 13px;
  background: #f1fbeF;
}

.card-stock-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.card-stock-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-stock,
.card-usage {
  text-align: left;
  background: rgba(244, 255, 240, 0.78);
  border: 1px solid rgba(53, 108, 66, 0.2);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #244b31;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analyze-btn {
  border: 1px solid #8eb38f;
  border-radius: 8px;
  background: linear-gradient(180deg, #66b271, #4f975a);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
  min-width: 86px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.analyze-btn:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.empty {
  margin: 10px 0;
  color: #5f7f65;
  font-size: 14px;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
}

.pager button {
  padding: 6px 10px;
  border: 1px solid #a8c7ad;
  background: #f6fff5;
  color: #2c5a3a;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.pager button:hover:not(:disabled) {
  background: var(--green-600);
  color: #fff;
}

.pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#pageInfo {
  font-size: 14px;
  color: var(--ink-soft);
}

.admin-float-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  text-decoration: none;
  border: 1px solid #8eb38f;
  border-radius: 999px;
  background: linear-gradient(180deg, #66b271, #4f975a);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 10px 14px;
  box-shadow: 0 8px 16px rgba(34, 83, 46, 0.24);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.admin-float-btn:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 20, 12, 0.62);
}

.image-modal.show {
  display: flex;
}

.image-modal-dialog {
  position: relative;
  width: min(1100px, 95vw);
  max-height: 92vh;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(195, 223, 190, 0.75);
  background: linear-gradient(180deg, #f8fff6, #eefbe9);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-dialog img {
  max-width: 100%;
  max-height: calc(92vh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #c6dec7;
}

.image-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 1px solid #9fbf9f;
  border-radius: 999px;
  background: #fff;
  color: #355c3b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.image-modal-close:hover {
  background: #e9f8e5;
}

.analysis-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 20, 12, 0.58);
}

.analysis-modal.show {
  display: flex;
}

.analysis-modal-dialog {
  position: relative;
  width: min(1020px, 96vw);
  max-height: 92vh;
  border-radius: 14px;
  border: 1px solid rgba(193, 224, 188, 0.9);
  background: linear-gradient(180deg, #f9fff8 0%, #eefbe9 100%);
  box-shadow: 0 24px 48px rgba(16, 40, 24, 0.24);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.analysis-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid #9fbf9f;
  border-radius: 999px;
  background: #fff;
  color: #2d5638;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.analysis-modal-close:hover {
  background: #e9f8e5;
}

.analysis-modal-head {
  padding: 14px 52px 12px 14px;
  border-bottom: 1px solid rgba(63, 118, 74, 0.2);
  background:
    radial-gradient(circle at 84% 8%, rgba(255, 255, 255, 0.4), transparent 30%),
    linear-gradient(180deg, #ccf1a7, #b5e58e);
}

.analysis-modal-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  color: #1f3d29;
}

.analysis-sub-title {
  margin: 4px 0 0;
  color: #2c5837;
  font-size: 13px;
  word-break: break-all;
}

.analysis-body {
  padding: 12px;
  overflow: auto;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 10px;
  align-items: start;
}

.analysis-panel {
  border: 1px solid #c7dfc7;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfffa, #f0fbec);
  padding: 12px;
  box-shadow: 0 8px 16px rgba(28, 69, 39, 0.08);
}

.analysis-panel:last-child {
  grid-column: 1 / -1;
}

.analysis-panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #21472e;
}

.analysis-loading {
  margin: 0;
  padding: 20px 6px;
  font-size: 14px;
  color: #456d50;
}

.analysis-tip {
  margin: 0 0 8px;
  font-size: 13px;
  color: #365c42;
  line-height: 1.45;
}

.analysis-advice {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #b2d7b6;
  background: #ebf9e8;
  font-size: 13px;
  line-height: 1.45;
  color: #1f4930;
  font-weight: 700;
}

.analysis-updated {
  margin: 8px 0 0;
  font-size: 12px;
  color: #537260;
}

.month-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.month-row {
  display: grid;
  grid-template-columns: 66px 1fr 54px;
  align-items: center;
  gap: 8px;
}

.month-label {
  font-size: 12px;
  color: #395e45;
  font-weight: 700;
}

.month-track {
  position: relative;
  height: 15px;
  border-radius: 999px;
  background: #e6f3e3;
  border: 1px solid #c6dec5;
  overflow: hidden;
}

.month-fill {
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  display: flex;
  min-width: 2px;
}

.month-segment {
  height: 100%;
}

.month-value {
  text-align: right;
  font-size: 12px;
  color: #2f573c;
  font-weight: 700;
}

.clerk-legend {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #33553e;
  border: 1px solid #c9dfca;
  border-radius: 999px;
  padding: 4px 8px;
  background: #f8fff7;
}

.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.share-row {
  display: grid;
  grid-template-columns: 74px 1fr 52px;
  align-items: center;
  gap: 8px;
}

.share-name {
  font-size: 12px;
  color: #33573f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #c6dec5;
  background: #ebf7e8;
}

.share-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.share-value {
  text-align: right;
  font-size: 12px;
  color: #2e563b;
  font-weight: 700;
}

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

.metric-box {
  border: 1px solid #c3ddc4;
  border-radius: 10px;
  background: #f5fff3;
  padding: 8px;
}

.metric-box strong {
  display: block;
  font-size: 12px;
  color: #41654b;
  margin-bottom: 4px;
}

.metric-box span {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: #20462d;
}

@media (max-width: 1260px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 980px) {
  .container {
    padding: 14px;
  }

  .hero {
    min-height: 90px;
    padding: 14px;
    gap: 8px;
    flex-direction: column;
    align-items: flex-start;
  }

  .hero h1 {
    font-size: 24px;
  }

  .hero-right {
    width: 100%;
    align-items: flex-start;
  }

  .session-info {
    width: 100%;
    border-radius: 8px;
  }

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

  .analysis-body {
    grid-template-columns: 1fr;
  }

  .analysis-panel:last-child {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .toolbar {
    gap: 8px;
  }

  .toolbar input[type="text"],
  .toolbar select,
  .toolbar button,
  .category-filter {
    width: 100%;
    min-width: 0;
  }

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

  .image-modal {
    padding: 12px;
  }

  .admin-float-btn {
    right: 12px;
    bottom: 12px;
    padding: 9px 12px;
    font-size: 12px;
  }

  .card-stock-row {
    flex-direction: column;
    align-items: stretch;
  }

  .analyze-btn {
    width: 100%;
  }

  .analysis-modal {
    padding: 10px;
  }

  .analysis-modal-dialog {
    width: 100%;
    max-height: 94vh;
  }

  .analysis-modal-head {
    padding: 12px 42px 10px 12px;
  }

  .analysis-modal-head h2 {
    font-size: 17px;
  }

  .analysis-body {
    padding: 10px;
  }

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

  .share-row {
    grid-template-columns: 66px 1fr 46px;
  }

  .month-row {
    grid-template-columns: 56px 1fr 48px;
  }
}
