:root {
  --paper: #f3eee2;
  --paper-deep: #e9dfcc;
  --paper-soft: #f8f3e8;
  --panel: #fffcf5;
  --panel-warm: #fbf7ec;
  --panel-muted: #f2eadb;
  --sidebar: #13251b;
  --sidebar-2: #16291f;
  --sidebar-hover: #20392b;
  --ink: #1f2a24;
  --text: #344139;
  --muted: #6e756f;
  --line: #d8cdb8;
  --line-strong: #c8b996;
  --green: #2f6b4f;
  --green-hover: #24563f;
  --green-soft: #e7f1e8;
  --green-ink: #23573f;
  --bronze: #8b6f3e;
  --bronze-light: #b08a42;
  --bronze-soft: #f4ead5;
  --tea: #9a6b32;
  --wood: #7a5431;
  --wood-dark: #4d3420;
  --wood-light: #b79358;
  --red: #b5473e;
  --red-hover: #963c35;
  --red-soft: #f5e4de;
  --shadow: 0 8px 24px rgba(63, 47, 31, 0.06);
  --shadow-strong: 0 18px 46px rgba(50, 38, 24, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --title-font: "Songti SC", "STSong", "Noto Serif SC", "Microsoft YaHei", serif;
  --body-font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --number-font: "DIN Alternate", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--body-font);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18px 22px, rgba(139, 111, 62, 0.04) 0 1px, transparent 1.6px),
    repeating-linear-gradient(0deg, rgba(111, 86, 45, 0.018) 0 1px, transparent 1px 24px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(210, 191, 153, 0.1)),
    var(--paper);
  background-size: 42px 42px, 100% 100%, 100% 100%, auto;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

button:disabled {
  box-shadow: none;
}

::selection {
  color: #fffdf6;
  background: var(--green);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(238, 230, 214, 0.72);
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 111, 62, 0.58);
  border: 2px solid rgba(238, 230, 214, 0.72);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(111, 86, 45, 0.78);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

body.auth-mode .app-shell {
  display: block;
}

body.auth-mode .sidebar,
body.auth-mode .topbar {
  display: none;
}

body.auth-mode .main {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

body.auth-mode .view {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
}

.sidebar {
  position: relative;
  overflow: hidden;
  color: #f7f1df;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  gap: 24px;
  background:
    linear-gradient(90deg, rgba(77, 52, 32, 0.9) 0 9px, rgba(183, 147, 88, 0.46) 9px 11px, transparent 11px),
    linear-gradient(180deg, rgba(22, 41, 31, 0.96), rgba(13, 28, 20, 0.98));
  box-shadow:
    inset -8px 0 18px rgba(0, 0, 0, 0.14),
    inset -1px 0 0 rgba(216, 205, 184, 0.18),
    12px 0 34px rgba(35, 29, 18, 0.15);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 42px 78px, rgba(176, 138, 66, 0.12), transparent 28px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035), transparent 16%, rgba(0, 0, 0, 0.1) 56%, transparent 86%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 16px);
  opacity: 0.88;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 10px;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 238, 192, 0.22), transparent 18%, rgba(0, 0, 0, 0.16) 58%, rgba(176, 138, 66, 0.16)),
    linear-gradient(90deg, var(--wood-dark), var(--wood), var(--wood-dark));
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 10px 18px;
  border: 1px solid rgba(216, 205, 184, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 252, 245, 0.08), rgba(122, 84, 49, 0.12)),
    rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(176, 138, 66, 0.85);
  background:
    linear-gradient(145deg, #8f3f32, #6f2c25),
    #7d342a;
  color: #fff4df;
  box-shadow:
    inset 0 0 0 3px rgba(255, 238, 210, 0.12),
    0 10px 20px rgba(0, 0, 0, 0.18);
  font-family: var(--title-font);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  color: #fff8e8;
  font-family: var(--title-font);
  font-size: 20px;
  font-weight: 700;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(247, 241, 223, 0.72);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  padding: 4px 0;
}

.nav button {
  position: relative;
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(216, 205, 184, 0.13);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.045), rgba(0, 0, 0, 0.04));
  color: rgba(247, 241, 223, 0.78);
  text-align: left;
  padding: 10px 12px 10px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.nav button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: transparent;
}

.nav button::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 5px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(176, 138, 66, 0.22), transparent);
}

.nav button span:first-child {
  font-weight: 600;
}

.nav button span:last-child {
  color: rgba(176, 138, 66, 0.85);
  font-size: 18px;
  line-height: 1;
}

.nav button:hover {
  background:
    linear-gradient(180deg, rgba(47, 107, 79, 0.34), rgba(32, 57, 43, 0.9));
  border-color: rgba(176, 138, 66, 0.28);
  color: #fff8e8;
}

.nav button.active {
  background:
    linear-gradient(90deg, rgba(47, 107, 79, 0.98), rgba(33, 78, 58, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
  border-color: rgba(176, 138, 66, 0.48);
  color: #fffdf4;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.14),
    0 10px 22px rgba(0, 0, 0, 0.14);
}

.nav button.active::before {
  background: var(--bronze-light);
}

.side-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(216, 205, 184, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(176, 138, 66, 0.22) 0 4px, transparent 4px),
    linear-gradient(135deg, rgba(255, 252, 245, 0.08), rgba(139, 111, 62, 0.12)),
    rgba(255, 255, 255, 0.04);
  color: rgba(247, 241, 223, 0.76);
  display: grid;
  gap: 11px;
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.text-button {
  width: fit-content;
  border: 0;
  color: var(--green);
  background: transparent;
  padding: 0;
  text-align: left;
  font-weight: 700;
}

.side-note .text-button {
  color: #f2dca7;
}

.text-button:hover {
  color: var(--bronze-light);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.sidebar,
.view,
.grid-two > *,
.panel,
.filters,
.stat,
.detail,
#inventoryTable,
#teaDetail,
#boxTable,
#boxDetail,
#movementTable {
  min-width: 0;
}

.topbar {
  min-height: 76px;
  border-bottom: 1px solid rgba(216, 205, 184, 0.8);
  background:
    linear-gradient(90deg, rgba(176, 138, 66, 0.14), transparent 24%),
    linear-gradient(180deg, rgba(255, 252, 245, 0.98), rgba(248, 243, 232, 0.92)),
    rgba(255, 252, 245, 0.92);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 30px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 24px rgba(77, 52, 32, 0.04);
}

.natural-query {
  flex: 1 1 390px;
  min-width: 300px;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 0 11px;
  border: 1px solid rgba(47, 107, 79, 0.68);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), transparent),
    var(--panel);
  box-shadow:
    inset 3px 0 0 var(--green),
    0 8px 18px rgba(47, 107, 79, 0.07);
}

.search-box {
  flex: 0 1 300px;
  min-width: 240px;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), transparent),
    repeating-linear-gradient(0deg, rgba(139, 111, 62, 0.035) 0 1px, transparent 1px 22px),
    var(--panel);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.58),
    0 8px 18px rgba(77, 52, 32, 0.05);
}

.natural-query span,
.search-box span,
.operator span {
  color: var(--bronze);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.natural-query span {
  color: var(--green-hover);
}

.search-box span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search-box span::before {
  content: "";
  width: 6px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--bronze-light), var(--bronze));
  opacity: 0.75;
}

.natural-query input,
.search-box input,
.operator select,
.field input,
.field select,
.field textarea,
.filters input,
.filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  min-height: 39px;
  padding: 8px 10px;
  outline: 0;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.search-box input {
  border: 0;
  min-height: 0;
  padding: 8px 2px;
  background: transparent;
  box-shadow: none;
}

.natural-query input {
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.natural-query button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #fffdf6;
  font-weight: 700;
  cursor: pointer;
}

.natural-query button:hover {
  background: var(--green-hover);
}

.natural-query button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.natural-query input:focus,
.search-box input:focus,
.operator select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.filters input:focus,
.filters select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.14);
}

.natural-query:focus-within {
  border-color: var(--green);
  box-shadow:
    inset 3px 0 0 var(--green),
    0 0 0 3px rgba(47, 107, 79, 0.12);
}

.search-box:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.1);
}

.query-interpretation {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 13px 16px;
  border-left: 3px solid var(--bronze-light);
  background:
    repeating-linear-gradient(0deg, rgba(139, 111, 62, 0.035) 0 1px, transparent 1px 23px),
    var(--panel-warm);
  color: var(--text);
}

.query-interpretation span {
  flex: 0 0 auto;
  color: var(--bronze);
  font-size: 12px;
  font-weight: 700;
}

.query-interpretation strong {
  font-weight: 600;
}

.query-empty strong {
  display: block;
  color: var(--text);
}

.query-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.action-candidates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.action-candidates em {
  padding: 4px 8px;
  border: 1px solid rgba(139, 111, 62, 0.24);
  border-radius: var(--radius-sm);
  background: var(--bronze-soft);
  color: #65512f;
  font-style: normal;
}

.action-draft {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-left: 3px solid var(--bronze-light);
  background:
    repeating-linear-gradient(0deg, rgba(139, 111, 62, 0.035) 0 1px, transparent 1px 23px),
    var(--panel-warm);
}

.action-draft span {
  display: block;
  margin-bottom: 3px;
  color: var(--bronze);
  font-size: 12px;
  font-weight: 700;
}

.action-draft strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

.action-draft p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.action-draft .ghost-button {
  flex: 0 0 auto;
}

.operator {
  min-width: 174px;
  display: grid;
  gap: 5px;
  padding: 0 0 0 12px;
  border-left: 1px solid rgba(216, 205, 184, 0.72);
}

.operator select {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(251, 247, 236, 0.92)),
    var(--panel);
  border-color: var(--line-strong);
}

.view {
  padding: 30px;
  display: grid;
  align-content: start;
  gap: 20px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 4px;
}

.page-head h2 {
  position: relative;
  margin: 0;
  color: var(--ink);
  font-family: var(--title-font);
  font-size: 28px;
  font-weight: 700;
}

.page-head h2::after {
  content: "";
  display: block;
  width: 54px;
  height: 2px;
  margin-top: 8px;
  background: linear-gradient(90deg, var(--bronze-light), rgba(176, 138, 66, 0));
}

.page-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.actions,
.filters,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.ghost-button,
.danger-button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 39px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.button {
  background: linear-gradient(180deg, #356f55, var(--green));
  color: #fffdf5;
  border-color: rgba(36, 86, 63, 0.52);
  box-shadow: 0 8px 18px rgba(47, 107, 79, 0.18);
}

.button:hover {
  background: linear-gradient(180deg, var(--green), var(--green-hover));
  box-shadow: 0 10px 22px rgba(47, 107, 79, 0.22);
}

.ghost-button {
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.92), rgba(244, 234, 213, 0.42));
  color: var(--ink);
  border-color: rgba(139, 111, 62, 0.35);
}

.ghost-button:hover {
  color: var(--green-hover);
  border-color: var(--green);
  background: var(--green-soft);
}

.danger-button {
  background: var(--panel);
  color: var(--red);
  border-color: rgba(181, 71, 62, 0.32);
}

.danger-button:hover {
  color: #fffdf5;
  background: var(--red);
  border-color: var(--red);
}

#outboundForm .button {
  background: linear-gradient(180deg, #a7473f, #8f3e37);
  border-color: rgba(143, 62, 55, 0.52);
  box-shadow: 0 8px 18px rgba(181, 71, 62, 0.16);
}

#outboundForm .button:hover {
  background: linear-gradient(180deg, var(--red), var(--red-hover));
}

#transferForm .button {
  background: linear-gradient(180deg, #917445, #765d34);
  border-color: rgba(139, 111, 62, 0.52);
  box-shadow: 0 8px 18px rgba(139, 111, 62, 0.16);
}

.actions .button {
  min-width: 62px;
}

.actions .ghost-button {
  color: #574a31;
}

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

.stat,
.panel,
.empty,
.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  position: relative;
  overflow: hidden;
  min-height: 122px;
  padding: 18px 18px 16px 20px;
  background:
    linear-gradient(90deg, rgba(47, 107, 79, 0.12) 0 6px, transparent 6px),
    radial-gradient(circle at 92% 20%, rgba(176, 138, 66, 0.12), transparent 34px),
    repeating-linear-gradient(0deg, rgba(139, 111, 62, 0.045) 0 1px, transparent 1px 24px),
    linear-gradient(180deg, #fffdf6, #faf4e7);
  border-color: rgba(200, 185, 150, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 -1px 0 rgba(139, 111, 62, 0.08),
    var(--shadow);
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background:
    linear-gradient(90deg, rgba(47, 107, 79, 0.86), rgba(176, 138, 66, 0.62), rgba(122, 84, 49, 0.12));
}

.stat::after {
  position: absolute;
  right: 16px;
  bottom: 10px;
  color: rgba(139, 111, 62, 0.16);
  font-family: var(--title-font);
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
}

.stat:nth-child(1)::after {
  content: "存";
}

.stat:nth-child(2)::after {
  content: "录";
}

.stat:nth-child(3)::after {
  content: "盒";
}

.stat:nth-child(4)::after {
  content: "量";
}

.stat span {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid rgba(176, 138, 66, 0.18);
  border-radius: 999px;
  background: rgba(244, 234, 213, 0.72);
  color: #65522e;
  font-size: 13px;
  font-weight: 700;
}

.stat strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 10px;
  color: var(--green-hover);
  font-family: var(--number-font);
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: 0;
}

.panel {
  padding: 18px;
  background:
    radial-gradient(circle at 100% 0, rgba(176, 138, 66, 0.07), transparent 44px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(251, 247, 236, 0.92)),
    var(--panel);
  border-color: rgba(216, 205, 184, 0.92);
}

.panel h3 {
  position: relative;
  margin: 0 0 14px;
  color: var(--ink);
  font-family: var(--title-font);
  font-size: 19px;
  font-weight: 700;
}

.panel h3::after {
  content: "";
  display: block;
  width: 38px;
  height: 1px;
  margin-top: 7px;
  background: var(--bronze-light);
  opacity: 0.65;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.filters {
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.96), rgba(251, 247, 236, 0.92)),
    var(--panel);
}

.filters input,
.filters select {
  width: auto;
  min-width: 154px;
  background: #fffdf7;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.96), rgba(251, 247, 236, 0.92)),
    var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
}

th,
td {
  border-bottom: 1px solid rgba(216, 205, 184, 0.76);
  padding: 12px 13px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, #efe2cc, #e7d9bf);
  color: #4d3f26;
  font-size: 13px;
  font-weight: 800;
  border-bottom-color: rgba(139, 111, 62, 0.35);
  box-shadow: inset 0 -1px 0 rgba(139, 111, 62, 0.18);
}

td strong {
  color: var(--ink);
}

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

tbody tr:nth-child(even) td {
  background: rgba(251, 247, 236, 0.5);
}

tr[data-tea],
tr[data-box] {
  cursor: pointer;
}

tr:hover td {
  background: #efe5d1;
}

.number {
  text-align: right;
  font-family: var(--number-font);
  font-variant-numeric: tabular-nums;
}

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid rgba(200, 185, 150, 0.8);
  border-radius: 999px;
  background: rgba(248, 243, 232, 0.88);
  color: #4b4537;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.chip.green {
  background: rgba(231, 241, 232, 0.82);
  color: var(--green-ink);
  border-color: rgba(47, 107, 79, 0.24);
}

.chip.amber {
  background: rgba(244, 234, 213, 0.9);
  color: #755822;
  border-color: rgba(176, 138, 66, 0.26);
}

.chip.blue {
  background: rgba(237, 240, 227, 0.88);
  color: #4f6047;
  border-color: rgba(139, 111, 62, 0.22);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.thumb {
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  color: var(--ink);
  text-decoration: none;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb span {
  padding: 6px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 252, 245, 0.94);
}

.thumb.missing img {
  display: none;
}

.thumb.missing::before {
  content: "未找到图片";
  display: grid;
  place-items: center;
  color: var(--red);
  font-size: 12px;
}

.thumb.more {
  display: grid;
  place-items: center;
  color: var(--bronze);
  font-weight: 800;
}

.tea-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.tea-cell > div {
  min-width: 0;
}

.tea-table-image {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(139, 111, 62, 0.26);
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(45deg, rgba(139, 111, 62, 0.04) 0 1px, transparent 1px 8px),
    var(--panel-warm);
  color: var(--bronze);
  font-family: var(--title-font);
  font-size: 18px;
}

.tea-table-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#teaDetail {
  display: grid;
  gap: 18px;
}

.tea-gallery {
  display: grid;
  gap: 14px;
}

.gallery-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(216, 205, 184, 0.72);
}

.gallery-head h3,
.gallery-head p {
  margin: 0;
}

.gallery-head p {
  margin-top: 6px;
}

.image-upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.image-upload-form input[type="file"] {
  width: 100%;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fffdf7;
  color: var(--muted);
}

.image-upload-form input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  padding: 5px 10px;
  border: 1px solid rgba(139, 111, 62, 0.35);
  border-radius: 4px;
  background: var(--panel-warm);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.tea-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.tea-photo-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 205, 184, 0.92);
  border-radius: var(--radius-sm);
  background: #fffdf7;
  box-shadow: 0 6px 16px rgba(63, 47, 31, 0.05);
}

.tea-photo-card.is-primary {
  border-color: rgba(176, 138, 66, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(176, 138, 66, 0.16),
    0 7px 18px rgba(63, 47, 31, 0.07);
}

.tea-photo-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-bottom: 1px solid rgba(216, 205, 184, 0.72);
  border-radius: 0;
  background: var(--panel-warm);
  cursor: zoom-in;
}

.tea-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.tea-photo-preview:hover img {
  transform: scale(1.025);
}

.cover-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 252, 245, 0.52);
  border-radius: 4px;
  background: rgba(47, 107, 79, 0.92);
  color: #fffdf5;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 3px 9px rgba(31, 42, 36, 0.18);
}

.tea-photo-info {
  display: grid;
  gap: 8px;
  padding: 9px;
}

.tea-photo-info > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tea-photo-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}

.icon-button,
.text-action,
.dialog-close {
  border: 1px solid rgba(139, 111, 62, 0.3);
  background: var(--panel-warm);
  color: var(--ink);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.icon-button {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-size: 16px;
}

.icon-button:hover,
.text-action:hover {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-hover);
}

.icon-button.danger {
  margin-left: auto;
  color: var(--red);
}

.icon-button.danger:hover {
  border-color: var(--red);
  background: rgba(181, 71, 62, 0.08);
  color: var(--red-hover);
}

.text-action {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.tea-image-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(24, 35, 29, 0.28);
}

.tea-image-dialog::backdrop {
  background: rgba(19, 37, 27, 0.72);
  backdrop-filter: blur(3px);
}

.tea-image-dialog img {
  width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  display: block;
  border-radius: 4px;
  background: #171c18;
}

.tea-image-dialog p {
  margin: 9px 42px 0 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-close {
  position: sticky;
  top: 0;
  z-index: 1;
  float: right;
  width: 34px;
  height: 34px;
  margin: 2px 2px -36px 0;
  padding: 0;
  border-radius: 4px;
  background: rgba(255, 252, 245, 0.94);
  color: var(--ink);
  font-size: 20px;
}

.empty.compact {
  padding: 24px 16px;
  box-shadow: none;
}

.detail {
  display: grid;
  gap: 15px;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid rgba(216, 205, 184, 0.72);
  padding-bottom: 12px;
}

.detail-title h3 {
  margin: 0;
}

.detail-title p {
  margin: 6px 0 0;
}

.detail-title strong {
  color: var(--green-hover);
  font-family: var(--number-font);
  font-size: 24px;
  white-space: nowrap;
}

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

.kv div {
  padding: 11px;
  border: 1px solid rgba(216, 205, 184, 0.8);
  border-radius: var(--radius-sm);
  background: var(--panel-warm);
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.wide {
  grid-column: span 3;
}

.field label,
.field > span {
  color: #574b36;
  font-size: 13px;
  font-weight: 700;
}

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

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 252, 245, 0.92), rgba(242, 234, 219, 0.72)),
    var(--panel);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  border: 1px solid rgba(176, 138, 66, 0.28);
  border-radius: var(--radius-sm);
  background: #1f2a24;
  color: #fff9ea;
  padding: 12px 15px;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.18s ease;
  pointer-events: none;
}

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

.type-in,
.type-out,
.type-transfer,
.type-adjust,
.type-check {
  font-weight: 800;
  white-space: nowrap;
  border-left: 3px solid currentColor;
}

.type-in {
  color: var(--green);
  background: rgba(231, 241, 232, 0.58);
}

.type-out {
  color: #9e463d;
  background: rgba(245, 228, 222, 0.58);
}

.type-transfer {
  color: var(--bronze);
  background: rgba(244, 234, 213, 0.66);
}

.type-adjust {
  color: var(--tea);
  background: rgba(242, 234, 219, 0.7);
}

.type-check {
  color: #66522e;
  background: rgba(238, 230, 214, 0.74);
}

.type-in::before,
.type-out::before,
.type-transfer::before,
.type-adjust::before,
.type-check::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 1px;
  background: currentColor;
  opacity: 0.72;
}

.login-card {
  width: 100%;
  padding: 24px;
}

.login-brand {
  margin-bottom: 18px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 107, 79, 0.08), rgba(176, 138, 66, 0.08)),
    var(--panel-warm);
  border-color: rgba(216, 205, 184, 0.84);
}

.login-brand h1 {
  color: var(--ink);
}

.login-brand p {
  color: var(--muted);
}

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

.login-note {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-left: 2px solid var(--bronze-light);
  background: rgba(176, 138, 66, 0.08);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.login-form .field.wide {
  grid-column: span 1;
}

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

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 6;
    padding: 12px;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(35, 29, 18, 0.12);
  }

  .sidebar > .brand,
  .side-note {
    display: none;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav button {
    min-width: max-content;
  }

  .topbar,
  .page-head {
    align-items: stretch;
    flex-direction: column;
    height: auto;
    padding: 14px;
  }

  .natural-query,
  .search-box,
  .operator {
    width: 100%;
    min-width: 0;
  }

  .natural-query,
  .search-box {
    flex: 0 0 auto;
  }

  .view {
    padding: 16px;
  }

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

  .field.wide {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .action-draft {
    align-items: stretch;
    flex-direction: column;
  }

  .action-draft .ghost-button {
    width: 100%;
  }

  .stats-grid,
  .kv {
    grid-template-columns: 1fr;
  }

  .filters {
    align-items: stretch;
  }

  .filters input,
  .filters select,
  .actions > *,
  .inline-actions > * {
    width: 100%;
  }

  .detail-title {
    display: grid;
  }

  .detail-title strong {
    white-space: normal;
  }

  .gallery-head,
  .image-upload-form {
    grid-template-columns: 1fr;
  }

  .gallery-head {
    display: grid;
  }

  .image-upload-form .button {
    width: 100%;
  }

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

  .tea-photo-actions {
    flex-wrap: wrap;
  }

  .text-action {
    order: 3;
    width: 100%;
  }
}
