:root {
  --ink: #17231f;
  --muted: #6f7d76;
  --line: #dfe7e1;
  --paper: #ffffff;
  --canvas: #f3f6f3;
  --green: #0c7a54;
  --green-dark: #075e41;
  --green-soft: #e8f5ee;
  --amber: #ad6b12;
  --red: #b5443d;
  --shadow: 0 12px 34px rgba(25, 48, 39, .08);
}
* { box-sizing: border-box; }
html { font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-width: 1160px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 31px; }
h2 { margin-bottom: 6px; font-size: 28px; letter-spacing: -.02em; }
h3 { margin-bottom: 0; font-size: 17px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 50% 20%, #e9f7ef, transparent 34%), #eef2ee; }
.login-card { width: 410px; padding: 44px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 14px; color: white; background: var(--green); font: 800 28px/1 Georgia, serif; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 10px; font-size: 21px; }
.stack-form { display: grid; gap: 16px; margin-top: 28px; text-align: left; }
label { display: grid; gap: 7px; color: #4f5e56; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #ccd8d0; border-radius: 8px; color: var(--ink); background: white; outline: none; transition: .15s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(12, 122, 84, .1); }
.form-error { min-height: 18px; margin: -5px 0 0; color: var(--red); font-size: 13px; text-align: center; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; width: 226px; display: flex; flex-direction: column; padding: 25px 16px 18px; color: white; background: #102c22; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 3px; color: #a4b9af; font-size: 12px; }
.main-nav { display: grid; gap: 8px; margin-top: 25px; }
.main-nav button { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 0; border-radius: 9px; color: #bcd0c7; background: transparent; text-align: left; }
.main-nav button:hover, .main-nav button.active { color: white; background: rgba(75, 194, 144, .18); }
.main-nav button span { width: 18px; font-size: 18px; text-align: center; }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding: 15px 8px 0; border-top: 1px solid rgba(255,255,255,.1); color: #a4b9af; font-size: 12px; }
.text-button { padding: 0; border: 0; color: #d5e1dc; background: transparent; font-size: 12px; }
.workspace { min-height: 100vh; margin-left: 226px; padding: 32px 34px 60px; }
.view { display: none; }
.view.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.page-head p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 9px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; padding: 10px 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 750; font-size: 13px; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.dark { color: white; background: #20382f; }
.button.ghost { border-color: #ccd8d0; color: #43534b; background: white; }
.button.danger { color: var(--red); border-color: #f0cfcc; background: #fff5f4; }
.button.wide { width: 100%; }
.quote-layout { display: grid; grid-template-columns: minmax(720px, 1fr) 250px; gap: 20px; align-items: start; }
.quote-editor { min-width: 0; display: grid; gap: 16px; }
.panel { min-width: 0; padding: 21px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 14px rgba(25,48,39,.035); }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 18px; }
.panel-title p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; gap: 15px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.status-pill { padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: 750; }
.status-pill.neutral { color: #6a756f; background: #eef2ef; }
.status-pill.saved { color: var(--green); background: var(--green-soft); }
.quote-items { display: grid; gap: 10px; }
.quote-line { display: grid; grid-template-columns: 52px minmax(170px, 1.5fr) 70px 85px 78px 84px 100px 26px; gap: 6px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.quote-line img { width: 52px; height: 52px; border-radius: 7px; object-fit: contain; background: #f3f5f3; }
.quote-line .line-description { min-width: 0; }
.quote-line .line-description strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.quote-line .line-description textarea { height: 37px; margin-top: 4px; padding: 6px 8px; font-size: 11px; }
.quote-line label { gap: 3px; font-size: 10px; }
.quote-line input { padding: 8px 7px; font-size: 12px; }
.quote-line .line-metric { color: #506057; font-size: 11px; line-height: 1.5; }
.line-total { font-size: 12px; font-weight: 800; text-align: right; }
.icon-button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; color: #637169; background: #edf2ee; font-size: 22px; }
.remove-line { border: 0; color: #9b5a55; background: transparent; font-size: 20px; }
.empty-state { display: grid; gap: 5px; justify-items: center; padding: 44px 15px; color: var(--muted); text-align: center; }
.empty-state strong { color: #536159; }
.empty-state span { font-size: 12px; }
.summary-card { position: sticky; top: 24px; padding: 22px; border: 1px solid #d8e4dc; border-radius: 12px; background: #fbfdfb; box-shadow: var(--shadow); }
.summary-card h3 { margin-bottom: 16px; }
.summary-card dl { margin: 0; }
.summary-card dl div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed #d9e3dc; }
.summary-card dt { color: var(--muted); font-size: 12px; }
.summary-card dd { margin: 0; font-size: 12px; font-weight: 750; }
.grand-total { display: grid; gap: 5px; margin-top: 18px; padding-top: 16px; border-top: 2px solid #b7c8bd; }
.grand-total span { color: var(--muted); font-size: 12px; }
.grand-total strong { color: var(--green-dark); font-size: 25px; }
.deposit { display: flex; justify-content: space-between; margin-top: 12px; padding: 10px; border-radius: 7px; color: var(--green-dark); background: var(--green-soft); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
.stat-card { padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.stat-card span { display: block; color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; margin-top: 4px; font-size: 24px; }
.toolbar, .modal-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.search-box { position: relative; flex: 1; display: block; }
.search-box span { position: absolute; left: 12px; top: 8px; color: #77867e; font-size: 19px; }
.search-box input { padding-left: 38px; }
.check-label { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.check-label input { width: auto; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.product-card { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.product-card-media { position: relative; height: 150px; display: grid; place-items: center; overflow: hidden; background: #f3f6f3; }
.product-card-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.product-card-media .no-image { color: #9aa69f; font-size: 12px; }
.missing-badge { position: absolute; top: 9px; right: 9px; padding: 4px 7px; border-radius: 99px; color: var(--amber); background: #fff7e7; font-size: 10px; font-weight: 750; }
.product-card-body { padding: 13px; }
.product-card-head { display: flex; justify-content: space-between; gap: 10px; }
.product-card-head strong { font-size: 13px; }
.product-card-head button { padding: 0; border: 0; color: var(--green); background: none; font-size: 11px; }
.product-card p { height: 33px; margin: 7px 0; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.5; }
.product-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 10px; }
.product-meta span { padding: 6px; border-radius: 5px; color: #526159; background: #f5f7f5; }
.product-price { display: block; margin-top: 9px; color: var(--green-dark); font-size: 15px; }
.pager { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.pager button { min-width: 32px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: white; font-size: 11px; }
.pager button.active { color: white; border-color: var(--green); background: var(--green); }
.history-list { display: grid; gap: 10px; }
.history-row { display: grid; grid-template-columns: 1.1fr 1.3fr .6fr .7fr .7fr 250px; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.history-row strong { display: block; }
.history-row small { color: var(--muted); }
.history-actions { display: flex; justify-content: flex-end; gap: 6px; }
.history-actions button { padding: 6px 9px; }
.modal { width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 22px 70px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(13, 29, 23, .62); backdrop-filter: blur(2px); }
.wide-modal { width: min(1080px, calc(100vw - 40px)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-toolbar { padding: 16px 22px 0; }
.editor-body { display: grid; grid-template-columns: 200px 1fr; gap: 20px; padding: 20px 22px; max-height: 65vh; overflow: auto; }
.image-editor { display: flex; flex-direction: column; gap: 9px; align-items: center; }
.image-editor img, #imagePlaceholder { width: 180px; height: 180px; object-fit: contain; border: 1px solid var(--line); border-radius: 9px; background: #f3f6f3; }
#imagePlaceholder { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.file-button { width: 180px; }
.file-button input { display: none; }
.image-editor small { color: var(--muted); font-size: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.modal-actions span { flex: 1; }
.picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-height: 58vh; padding: 0 22px; overflow: auto; }
.picker-card { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: white; text-align: left; }
.picker-card:hover { border-color: var(--green); box-shadow: 0 0 0 2px rgba(12,122,84,.08); }
.picker-card img, .picker-card .no-image { width: 100%; height: 110px; display: grid; place-items: center; object-fit: contain; color: #9aa69f; background: #f3f6f3; }
.picker-card div:last-child { padding: 10px; }
.picker-card strong, .picker-card span { display: block; }
.picker-card strong { font-size: 12px; }
.picker-card span { height: 30px; margin: 4px 0; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.45; }
.picker-card b { color: var(--green-dark); font-size: 12px; }
.toast { position: fixed; right: 25px; bottom: 25px; z-index: 20; transform: translateY(20px); padding: 12px 17px; border-radius: 8px; color: white; background: #19392d; opacity: 0; pointer-events: none; transition: .2s; box-shadow: var(--shadow); font-size: 13px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #8f352f; }
.print-sheet { display: none; }
@media (max-width: 1350px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quote-layout { grid-template-columns: minmax(720px, 1fr); }
  .summary-card { position: static; }
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { min-width: 0; background: white; }
  .no-print, .sidebar, #productsView, #historyView, dialog, .toast { display: none !important; }
  .workspace { margin: 0; padding: 0; }
  #quoteView { display: block !important; }
  .print-sheet { display: block; color: #111; font: 10px/1.35 Arial, sans-serif; }
  .print-head { display: flex; justify-content: space-between; padding-bottom: 10px; border-bottom: 2px solid #15724f; }
  .print-head h1 { margin: 0 0 4px; color: #145f45; font-size: 24px; }
  .print-head p { margin: 2px 0; }
  .print-title { text-align: right; }
  .print-title strong { display: block; font-size: 20px; }
  .print-customer { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 16px; margin: 10px 0; padding: 8px; background: #f2f6f3; }
  .print-customer span { color: #5d6d64; }
  .print-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .print-table th, .print-table td { padding: 5px; border: 1px solid #bac8c0; vertical-align: middle; }
  .print-table th { color: white; background: #185f47; font-size: 8px; }
  .print-table img { width: 45px; height: 45px; object-fit: contain; }
  .print-table .desc { font-size: 8px; }
  .print-summary { display: grid; grid-template-columns: 1.5fr 1fr; gap: 15px; margin-top: 10px; }
  .print-terms { padding: 8px; border: 1px solid #cad4ce; }
  .print-terms p { margin: 2px 0; }
  .print-totals { margin-left: auto; width: 100%; border-collapse: collapse; }
  .print-totals td { padding: 4px 7px; border-bottom: 1px solid #dbe2de; }
  .print-totals td:last-child { text-align: right; font-weight: 700; }
  .print-totals .total td { color: #145f45; border-top: 2px solid #145f45; font-size: 14px; }
  .print-foot { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 7px; border-top: 1px solid #cdd6d1; color: #64716a; font-size: 8px; }
}
