:root {
  --ink: #15231d;
  --muted: #68756e;
  --line: #dfe6e1;
  --soft: #f3f6f4;
  --canvas: #edf1ee;
  --white: #ffffff;
  --green: #0d684b;
  --green-2: #16805d;
  --mint: #d9eee6;
  --amber: #c47a16;
  --amber-soft: #fff0d5;
  --red: #b63c35;
  --red-soft: #fbe6e3;
  --blue: #316f8c;
  --blue-soft: #e3f0f6;
  --shadow: 0 10px 30px rgba(20, 43, 33, .08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1120px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px; color: #eef8f3; background: #123c2f; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 28px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: #123c2f; font-weight: 800; background: #d7f3e6; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand span { margin-top: 4px; font-size: 11px; color: #a9c7bb; }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 0; border-radius: 10px; color: #c8ddd4; background: transparent; text-align: left; }
.nav-item span { width: 20px; font-size: 17px; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.11); }
.sidebar-note { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 13px; border: 1px solid rgba(255,255,255,.12); border-radius: 11px; background: rgba(255,255,255,.06); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #72d6a9; box-shadow: 0 0 0 4px rgba(114,214,169,.12); }
.storage-warning .status-dot { background: #f0b05a; box-shadow: 0 0 0 4px rgba(240,176,90,.14); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note small { margin-top: 2px; color: #a9c7bb; font-size: 10px; }
.sidebar-reset { margin: 12px auto 0; color: #9ebbad !important; font-size: 11px; }
.workspace { min-width: 0; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.topbar h1 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.03em; }
.eyebrow, .section-kicker { margin: 0; color: var(--green-2); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.operator-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.operator-field input { width: 92px; padding: 8px 9px; }
main { padding: 26px 32px 48px; }
.view { display: none; }
.view.active { display: block; }
.hero-panel { position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: flex-end; min-height: 170px; padding: 30px 34px; border-radius: 17px; color: white; background: linear-gradient(128deg, #123c2f 0%, #0c6a4b 60%, #208260 100%); box-shadow: var(--shadow); }
.hero-panel::after { content: ""; position: absolute; width: 250px; height: 250px; right: 15%; top: -115px; border: 55px solid rgba(255,255,255,.06); border-radius: 50%; }
.hero-panel h2 { max-width: 620px; margin: 13px 0 8px; font-size: 28px; line-height: 1.25; letter-spacing: -.03em; }
.hero-panel p { margin: 0; color: #cce4da; }
.pill { display: inline-flex; padding: 5px 9px; border: 1px solid rgba(255,255,255,.26); border-radius: 999px; color: #daf0e7; font-size: 11px; background: rgba(255,255,255,.08); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: 13px; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { color: white; background: var(--green); }
.btn.primary:hover { background: #09573f; }
.btn.secondary { color: var(--ink); border-color: var(--line); background: white; }
.btn.secondary:hover { border-color: #b9c8c0; }
.btn.danger { color: white; background: var(--red); }
.btn.danger:hover { background: #992f29; }
.btn.light { position: relative; z-index: 1; color: var(--green); background: white; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
#dashboardMetrics { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.metric-grid.compact { margin-top: 16px; }
.metric-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: 0 3px 15px rgba(24,44,35,.04); }
.metric-card span { display: block; color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; margin-top: 8px; font-size: 22px; letter-spacing: -.04em; }
.metric-card small { display: block; margin-top: 5px; color: #92a097; font-size: 10px; }
.metric-card.emphasis { color: white; border-color: var(--green); background: var(--green); }
.metric-card.emphasis span, .metric-card.emphasis small { color: #cde3da; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 4px 18px rgba(21,35,29,.04); }
.panel + .panel { margin-top: 18px; }
.dashboard-grid .panel + .panel { margin-top: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding: 19px 21px 14px; }
.panel-heading h3 { margin: 4px 0 0; font-size: 16px; }
.bar-chart { padding: 8px 21px 22px; }
.bar-row { display: grid; grid-template-columns: 76px 1fr 30px; gap: 10px; align-items: center; margin-top: 12px; font-size: 12px; }
.bar-track { height: 8px; overflow: hidden; border-radius: 99px; background: #edf2ef; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #27a477, #0c684a); }
.attention-list { padding: 2px 20px 20px; }
.attention-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid #edf1ee; }
.attention-item:first-child { border-top: 0; }
.attention-item strong, .attention-item span { display: block; }
.attention-item strong { font-size: 13px; }
.attention-item span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.text-button, .back-link { border: 0; color: var(--green); background: none; font-weight: 700; font-size: 12px; }
.text-button[href] { text-decoration: none; }
.page-toolbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 6px; }
.page-toolbar h2 { margin: 0; font-size: 24px; }
.page-toolbar p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.filter-panel { padding: 15px 18px 17px; margin: 16px 0; }
.quick-filters { display: flex; gap: 7px; padding-bottom: 14px; border-bottom: 1px solid #edf1ee; }
.chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: white; font-size: 12px; }
.chip.active, .chip:hover { color: white; border-color: var(--green); background: var(--green); }
.filter-grid { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); gap: 12px; padding-top: 14px; }
.material-filters { grid-template-columns: 2fr 1fr 1fr; max-width: 720px; padding-top: 0; }
label { color: #59665f; font-size: 11px; font-weight: 700; }
input, select, textarea { width: 100%; margin-top: 6px; padding: 9px 10px; border: 1px solid #ccd6d0; border-radius: 8px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #5b9f85; box-shadow: 0 0 0 3px rgba(13,104,75,.08); }
textarea { resize: vertical; }
.helper { margin: 12px 0 0; color: var(--muted); font-size: 11px; }
.table-panel { overflow: hidden; }
.table-meta { display: flex; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 13px; color: #6f7b75; background: #f5f7f6; font-size: 10px; letter-spacing: .04em; text-align: left; white-space: nowrap; }
td { padding: 12px 13px; border-top: 1px solid #edf1ee; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
.product-link { padding: 0; border: 0; color: var(--green); background: none; font-weight: 800; text-align: left; }
.product-code { display: block; margin-top: 4px; color: #87928c; font-size: 10px; font-weight: 500; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.green { color: #0b694b; background: var(--mint); }
.badge.amber { color: #92580c; background: var(--amber-soft); }
.badge.red { color: #97332d; background: var(--red-soft); }
.badge.blue { color: #285f78; background: var(--blue-soft); }
.badge.gray { color: #5e6963; background: #e9eeeb; }
.progress { min-width: 68px; }
.progress-bar { height: 5px; margin-top: 5px; overflow: hidden; border-radius: 99px; background: #e7ece9; }
.progress-bar i { display: block; height: 100%; border-radius: 99px; background: var(--green-2); }
.empty { padding: 28px !important; color: var(--muted); text-align: center; }
.back-link { padding: 0; margin-bottom: 14px; }
.detail-hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; padding: 24px 26px; border-radius: 15px; color: white; background: #174737; }
.detail-hero h2 { margin: 7px 0 4px; font-size: 26px; }
.detail-hero p { margin: 0; color: #bfd9cf; font-size: 12px; }
.detail-summary { display: grid; grid-template-columns: repeat(4, 120px); gap: 9px; }
.detail-summary div { padding: 11px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(255,255,255,.07); }
.detail-summary span, .detail-summary strong { display: block; }
.detail-summary span { color: #bcd7cd; font-size: 9px; }
.detail-summary strong { margin-top: 6px; font-size: 15px; }
.detail-tabs { display: flex; gap: 8px; margin: 17px 0 13px; }
.tab-button { padding: 9px 14px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: white; font-size: 12px; font-weight: 800; }
.tab-button.active { color: white; border-color: var(--green); background: var(--green); }
.detail-panel { padding: 22px; }
.detail-panel .panel-heading { padding: 0 0 16px; }
.profile-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; }
.profile-main { min-width: 0; }
.product-image-card { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #f7faf8; }
.product-image-card img, .product-image-placeholder { width: 100%; aspect-ratio: 4 / 3; border-radius: 9px; }
.product-image-card img { display: block; object-fit: cover; background: var(--soft); }
.zoomable-image { cursor: zoom-in; }
.product-image-placeholder { display: grid; place-content: center; gap: 6px; color: #839087; text-align: center; background: linear-gradient(145deg, #edf3ef, #f8faf9); }
.product-image-placeholder strong { color: #526158; font-size: 13px; }
.product-image-placeholder span { font-size: 10px; }
.image-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 11px; }
.product-image-card small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sort-controls, .row-actions { display: inline-flex; align-items: center; gap: 5px; }
.sort-controls > span { min-width: 18px; color: var(--muted); font-size: 11px; text-align: center; }
.mini-icon { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--green); background: white; font-weight: 800; }
.mini-icon:hover { border-color: #9ebbad; background: var(--soft); }
.recipe-section { margin-top: 18px; padding-top: 2px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.recipe-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #f1f6f3; }
.recipe-section-heading > div { display: flex; align-items: center; gap: 10px; }
.recipe-section-heading strong { color: var(--green); }
.recipe-section-heading span { color: var(--muted); font-size: 11px; }
.recipe-section-heading b { color: var(--ink); font-size: 14px; }
.recipe-section .table-wrap { border-top: 1px solid var(--line); }
.evidence-cell { min-width: 230px; }
.evidence-actions { display: flex; align-items: center; gap: 9px; margin-top: 6px; flex-wrap: wrap; }
.evidence-actions .text-button { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(8,20,15,.9); cursor: zoom-out; }
.image-lightbox::backdrop { background: rgba(8,20,15,.9); }
.image-lightbox[open] { display: grid; place-items: center; }
.image-lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 10px; box-shadow: 0 20px 70px rgba(0,0,0,.45); cursor: zoom-out; }
.image-lightbox span { position: fixed; bottom: 22px; color: rgba(255,255,255,.75); font-size: 12px; }
.lightbox-close { position: fixed; top: 18px; right: 24px; z-index: 2; width: 42px; height: 42px; border: 0; border-radius: 50%; color: white; background: rgba(255,255,255,.14); font-size: 28px; }
.key-value-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.key-value { padding: 13px; border-radius: 10px; background: #f4f7f5; }
.key-value span, .key-value strong { display: block; }
.key-value span { color: var(--muted); font-size: 10px; }
.key-value strong { margin-top: 6px; font-size: 13px; }
.detail-description { margin-top: 15px; padding: 14px; color: #536158; border-left: 3px solid #86bda8; background: #f4f8f6; font-size: 12px; line-height: 1.7; }
.inline-actions { display: flex; gap: 8px; }
.data-table-input { min-width: 70px; margin: 0; padding: 7px; font-size: 11px; }
.material-code-input { min-width: 110px; }
.recipe-code { min-width: 190px; }
.recipe-name { min-width: 150px; }
.row-delete { border: 0; color: var(--red); background: transparent; font-size: 16px; }
.sub-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.sub-metric { padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.sub-metric span, .sub-metric strong { display: block; }
.sub-metric span { color: var(--muted); font-size: 10px; }
.sub-metric strong { margin-top: 6px; font-size: 16px; }
.table-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 15px; }
.modal { width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 24px 80px rgba(14,32,24,.3); }
.modal::backdrop { background: rgba(15,31,24,.45); backdrop-filter: blur(3px); }
.modal form { padding: 23px; }
.combo-modal { width: min(1120px, calc(100vw - 32px)); }
.combo-modal form { max-height: calc(100vh - 48px); overflow: auto; }
.combo-editor-top { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; padding: 20px 0 14px; align-items: start; }
.combo-basic-grid { padding: 0; }
.combo-image-card { min-width: 0; }
.combo-image-card #comboImagePreview > img { width: 100%; aspect-ratio: 4 / 3; border-radius: 9px; object-fit: cover; display: block; }
.combo-thumbnail, .combo-thumbnail-placeholder { width: 58px; height: 44px; border-radius: 8px; }
.combo-thumbnail { display: block; object-fit: cover; cursor: zoom-in; background: var(--soft); }
.combo-thumbnail-placeholder { display: grid; place-items: center; color: #7b8b82; background: #edf3ef; font-size: 10px; font-weight: 800; }
.combo-live-metrics { margin-bottom: 4px; }
.combo-section { margin-top: 14px; }
.combo-reference { min-width: 230px; }
.combo-content { min-width: 220px; line-height: 1.6; }
.check-option { display: flex; align-items: center; gap: 9px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.check-option input { width: auto; margin: 0; }
.modal-card { padding: 23px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 4px 0 0; font-size: 21px; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 8px; color: var(--muted); background: var(--soft); font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px 0; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }
.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 9px; margin: 20px 0; padding: 30px; border: 1.5px dashed #b8c8bf; border-radius: 12px; background: #f6f9f7; }
.drop-zone.dragover { border-color: var(--green); background: #edf7f2; }
.drop-zone span { color: var(--muted); font-size: 11px; }
.import-preview { padding: 14px; border-radius: 10px; color: #355347; background: #edf7f2; font-size: 12px; line-height: 1.7; }
.import-mode { display: flex; gap: 20px; margin: 15px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.import-mode legend { color: var(--muted); font-size: 10px; }
.import-mode label { display: flex; align-items: center; gap: 6px; }
.import-mode input { width: auto; margin: 0; }
.confirm-modal { width: min(540px, calc(100vw - 40px)); }
.confirm-content { padding: 20px 0; line-height: 1.7; }
.confirm-content p { margin: 0 0 14px; }
.danger-note { padding: 12px 14px; border: 1px solid #f1c7c3; border-radius: 9px; color: #8e302b; background: var(--red-soft); font-size: 12px; }
.danger-text { color: var(--red); }
.hidden { display: none !important; }
.toast { position: fixed; right: 26px; bottom: 24px; z-index: 20; min-width: 240px; max-width: 420px; padding: 13px 16px; border-radius: 10px; color: white; background: #173d30; box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translateY(0); }

.cloud-app-hidden { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 20%, #dff1e8 0, transparent 36%), linear-gradient(135deg, #f5f8f6, #e9f1ed); }
.auth-card { width: min(420px, calc(100vw - 36px)); padding: 30px; border: 1px solid rgba(24, 94, 67, .12); border-radius: 22px; background: rgba(255,255,255,.96); box-shadow: 0 26px 80px rgba(19, 65, 47, .14); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.auth-brand strong, .auth-brand span { display: block; }
.auth-brand span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.auth-card h1 { margin: 0 0 8px; font-size: 25px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.auth-form { display: grid; gap: 15px; }
.auth-form .btn { margin-top: 5px; min-height: 43px; }
.auth-switch { margin-top: 18px; }
.auth-message { margin-top: 18px; padding: 12px 14px; border-radius: 10px; color: #275b46; background: #e8f4ee; font-size: 12px; line-height: 1.6; }
.auth-message.error { color: #8e302b; background: var(--red-soft); }
.account-badge { max-width: 220px; overflow: hidden; padding: 7px 10px; border-radius: 99px; color: #315c4b; background: #e8f3ee; font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.users-modal { width: min(900px, calc(100vw - 40px)); }
.users-modal .table-wrap { max-height: 55vh; margin-top: 16px; }
.user-email { display: block; margin-top: 4px; color: var(--muted); }
.user-active { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.user-active input { width: auto; margin: 0; }
.readonly .sidebar-note .status-dot { background: #4a7cac; }
.readonly #operatorInput { color: var(--muted); background: #f2f5f3; }

@media (max-width: 1280px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  #dashboardMetrics { grid-template-columns: repeat(4, 1fr); }
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-summary { grid-template-columns: repeat(2, 120px); }
  .combo-editor-top { grid-template-columns: 190px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .combo-editor-top { grid-template-columns: 1fr; }
  .combo-image-card { max-width: 320px; }
}

@media print {
  .sidebar, .topbar, .back-link, .detail-tabs, .inline-actions, .table-actions, .row-delete { display: none !important; }
  .app-shell { display: block; }
  main { padding: 0; }
  .view { display: none !important; }
  #detailView.active { display: block !important; }
  .detail-hero { color: #000; border: 1px solid #ccc; background: white; }
  .detail-hero p, .detail-summary span { color: #555; }
  .detail-summary div { border-color: #ccc; background: white; }
}
