:root {
  --ink: #18322e;
  --muted: #647571;
  --paper: #f4f6f2;
  --card: #ffffff;
  --green: #17423b;
  --green-2: #246b5e;
  --mint: #dcece5;
  --amber: #f4a340;
  --red: #bd3e3e;
  --line: #dce4df;
  --shadow: 0 8px 24px rgba(24, 50, 46, .08);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body { background: linear-gradient(180deg, #edf4ef 0, var(--paper) 220px); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 66px; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px; color: white;
  background: rgba(23, 66, 59, .96); backdrop-filter: blur(12px);
}
.topbar > div { flex: 1; min-width: 0; }
.app-name { font-size: 12px; opacity: .72; }
.page-title { font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button { min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; color: white; background: rgba(255,255,255,.12); font-size: 24px; }
.page { width: min(100%, 940px); margin: 0 auto; padding: 18px 14px calc(92px + env(safe-area-inset-bottom)); }
.bottom-nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line); backdrop-filter: blur(15px);
}
.bottom-nav a { min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); text-decoration: none; font-size: 11px; line-height: 1; white-space: nowrap; border-radius: 9px; }
.bottom-nav a span { font-size: 16px; line-height: 1; font-weight: 800; }
.bottom-nav a.active { color: var(--green); background: var(--mint); }
.hero { padding: 18px; color: white; border-radius: 20px; background: linear-gradient(135deg, #17423b, #2d7c6d); box-shadow: var(--shadow); }
.hero h2 { margin: 0 0 6px; font-size: 24px; }
.hero p { margin: 0; opacity: .8; }
.search-box { display: flex; gap: 8px; margin: 14px 0; }
.search-box input { flex: 1; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0; }
.stat { padding: 15px; min-height: 105px; border-radius: 17px; background: var(--card); box-shadow: var(--shadow); }
.stat strong { display: block; margin-top: 8px; font-size: 29px; }
.stat small { color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 2px 10px; }
.section-head h2, .section-head h3 { margin: 0; font-size: 18px; }
.card { margin: 10px 0; padding: 15px; background: var(--card); border: 1px solid rgba(220,228,223,.8); border-radius: 16px; box-shadow: 0 4px 15px rgba(24,50,46,.05); }
.card.clickable { cursor: pointer; }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-body { flex: 1; min-width: 0; }
.production-order-heading { padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.production-order-heading small { display: block; margin-top: 3px; color: var(--muted); }
.production-order-group > .card { margin: 10px 0 0; }
.order-customer-heading { padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.order-customer-heading small { display: block; margin-top: 3px; color: var(--muted); }
.order-customer-group > .card { margin: 10px 0 0; }
.order-product-list { margin: 8px 0; }
.order-product-line { padding: 2px 0; overflow-wrap: anywhere; }
.order-product-line a { color: var(--ink); font-weight: 700; text-decoration: none; }
.card:has(.production-menu) { position: relative; }
.production-actions { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.production-menu-button { min-width: 30px; min-height: 30px; padding: 0 5px; border: 0; border-radius: 8px; font-size: 22px; line-height: 1; }
.production-menu { position: absolute; z-index: 3; right: 14px; margin-top: -4px; padding: 4px; background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.production-menu[hidden] { display: none; }
.production-menu button { min-height: 40px; color: var(--red); border: 0; }
.production-data-line { overflow: auto; white-space: nowrap; font-size: 12px; scrollbar-width: thin; }
.production-data-line::-webkit-scrollbar { height: 3px; }
.production-data-line::-webkit-scrollbar-thumb { background: #a6bdb1; border-radius: 3px; }
.production-data-line.can-scroll::before { content: '↔ '; color: var(--green-2); }
.production-delete-dialog { width: min(390px, calc(100% - 28px)); padding: 18px; border: 0; border-radius: 17px; color: var(--ink); box-shadow: 0 15px 40px rgba(0,0,0,.22); }
.production-delete-dialog::backdrop { background: rgba(10,25,20,.5); }
.production-delete-dialog h3 { margin-top: 0; }
.production-delete-dialog .actions { justify-content: flex-end; }
.card h3, .card h4 { margin: 0 0 5px; }
.card p { margin: 4px 0; }
.product-specs { line-height: 1.55; overflow-wrap: anywhere; }
.product-code { font-size: 12px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big-number { font-size: 30px; font-weight: 800; line-height: 1.1; }
.thumb { width: 62px; height: 62px; flex: 0 0 62px; border-radius: 14px; object-fit: cover; background: var(--mint); }
.thumb.placeholder { display: grid; place-items: center; color: var(--green); font-weight: 800; font-size: 20px; }
.detail-image { width: 100%; max-height: 300px; object-fit: contain; border-radius: 18px; background: #e8ede9; }
.pill { display: inline-flex; align-items: center; min-height: 27px; padding: 3px 9px; border-radius: 999px; background: var(--mint); color: var(--green); font-size: 12px; }
.pill.warn { background: #fff0dc; color: #8b5109; }
.pill.danger { background: #fde4e4; color: var(--red); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { padding: 12px 8px; text-align: center; background: #f5f8f5; border-radius: 12px; }
.metric strong { display: block; font-size: 19px; }
label { display: block; margin: 12px 0 6px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid #bfcac4; border-radius: 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(36,107,94,.12); }
textarea { min-height: 86px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
button, .button { min-height: 46px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; font-weight: 700; cursor: pointer; text-decoration: none; }
button.primary, .button.primary { color: white; background: var(--green); border-color: var(--green); }
button.danger { color: var(--red); border-color: #efbaba; }
button:disabled { opacity: .55; cursor: wait; }
.full { width: 100%; }
.alert { margin: 10px 0; padding: 12px; border-radius: 12px; background: #e8f3ee; }
.alert.warn { background: #fff0dc; color: #754506; }
.alert.danger { background: #fde4e4; color: #8c2828; }
.danger-zone { margin-top: 24px; border-color: #efbaba; background: #fffafa; }
.danger-zone h3 { color: var(--red); }
.empty, .loading, .error-state { padding: 42px 20px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 20px; height: 20px; margin-right: 8px; vertical-align: middle; border: 3px solid #cbd8d1; border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 99; left: 50%; bottom: 88px; width: max-content; max-width: calc(100% - 32px); transform: translateX(-50%); padding: 11px 16px; color: white; background: #18322e; border-radius: 12px; box-shadow: var(--shadow); }
.list-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf0ed; }
.list-line:last-child { border-bottom: 0; }
.positive { color: var(--green-2); font-weight: 800; }
.negative, .shortage { color: var(--red); font-weight: 800; }
.line-editor { padding: 12px; margin: 10px 0; background: #f4f7f4; border-radius: 12px; }
.type-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.type-switch .type-option { min-width: 0; padding: 10px 6px; }
.type-switch .type-option.active { color: white; background: var(--green); border-color: var(--green); }
.type-switch .type-option.add { color: var(--green-2); border-style: dashed; }
.input-unit { position: relative; }
.input-unit input { padding-right: 48px; }
.input-unit span { position: absolute; right: 13px; top: 13px; color: var(--muted); font-weight: 500; pointer-events: none; }
.weight-calculation { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.weight-calculation button { min-height: 44px; padding: 6px 10px; font-size: 13px; }
.subsection { margin: 18px 0; padding-top: 4px; border-top: 1px solid var(--line); }
.subsection > h3 { margin: 12px 0 4px; }
.suggestions { margin-top: -2px; border: 1px solid var(--line); border-radius: 10px; background: white; overflow: hidden; }
.suggestions button { width: 100%; min-height: 42px; padding: 8px 10px; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.suggestions button:last-child { border-bottom: 0; }
.association-picker { position: relative; margin-top: 4px; }
.association-picker > input { padding-right: 52px; }
.association-picker-toggle {
  position: absolute; top: 2px; right: 2px; width: 42px; min-height: 42px; padding: 0;
  border: 0; border-radius: 9px; color: var(--green); background: transparent; font-size: 26px;
}
.association-picker-list {
  max-height: min(280px, 42vh); margin-top: 4px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow);
}
.association-picker-list[hidden] { display: none; }
.association-picker-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; min-height: 48px; padding: 9px 12px; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: white;
  font-weight: 400; overflow-wrap: anywhere;
}
.association-picker-option:last-of-type { border-bottom: 0; }
.association-picker-option:hover, .association-picker-option.active { background: var(--mint); }
.association-picker-option small { color: var(--muted); font-size: 12px; }
.association-picker-hint { padding: 12px; color: var(--muted); font-size: 13px; font-weight: 400; }
.inline-unit { position: relative; }
.inline-unit input { padding-right: 38px; }
.inline-unit span { position: absolute; right: 12px; bottom: 13px; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: #e4ebe6; border-radius: 13px; }
.tabs button { border: 0; background: transparent; }
.tabs button.active { background: white; box-shadow: 0 2px 8px rgba(0,0,0,.07); }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-grid a { min-height: 88px; padding: 14px; display: flex; align-items: flex-end; color: var(--ink); background: white; border-radius: 15px; box-shadow: var(--shadow); text-decoration: none; font-weight: 750; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 390px); padding: 28px; background: white; border-radius: 22px; box-shadow: var(--shadow); }
.login-card h1 { text-align: center; }
.brand-mark { width: 58px; height: 58px; margin: auto; display: grid; place-items: center; color: white; background: var(--green); border-radius: 17px; font-size: 26px; font-weight: 800; }
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav { left: 50%; max-width: 700px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
  .page { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 390px) {
  .page { padding-left: 10px; padding-right: 10px; }
  .metrics { gap: 5px; }
  .metric { padding: 10px 4px; }
  .metric strong { font-size: 17px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .bottom-nav { padding-left: 3px; padding-right: 3px; }
  .bottom-nav a { font-size: 10px; }
}

