:root {
  --ink: #142b38;
  --ink-soft: #50636e;
  --muted: #788b94;
  --line: #d8e1e3;
  --line-strong: #bccacc;
  --paper: #fffefa;
  --surface: #f5f8f8;
  --surface-2: #edf3f3;
  --navy: #12384f;
  --navy-2: #1b536d;
  --teal: #087f83;
  --teal-bright: #13a3a0;
  --teal-pale: #e5f6f4;
  --amber: #c97731;
  --amber-pale: #fff4e7;
  --red: #b54c4c;
  --shadow-sm: 0 2px 10px rgba(19, 48, 61, 0.06);
  --shadow-md: 0 14px 40px rgba(15, 47, 61, 0.12);
  --shadow-lg: 0 24px 70px rgba(15, 47, 61, 0.18);
  --radius: 14px;
  --font: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #e8eef0; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -5%, rgba(30, 139, 139, 0.16), transparent 30rem),
    radial-gradient(circle at 92% 5%, rgba(17, 56, 79, 0.1), transparent 35rem),
    #e8eef0;
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.topbar {
  height: 72px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 252, 0.94);
  border-bottom: 1px solid rgba(24, 59, 74, 0.1);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  text-decoration: none;
  min-width: 224px;
}
.brand-mark {
  width: 148px;
  height: 50px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  mix-blend-mode: multiply;
}
.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.brand-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 19px; letter-spacing: 1.7px; }
.brand-copy small { color: var(--navy); font-size: 11px; font-weight: 750; letter-spacing: 0.1em; white-space: nowrap; }
.logged-in-user {
  min-width: 98px;
  min-height: 40px;
  padding: 5px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.logged-in-user:hover { background: rgba(239, 245, 244, 0.9); border-color: transparent; }
.logged-in-user span { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 0.06em; }
.logged-in-user strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--navy); font-size: 11px; }
.main-nav {
  height: 40px;
  padding: 3px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(239, 245, 244, 0.82);
}
.back-button {
  height: 34px;
  min-width: 86px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.8);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
  cursor: pointer;
}
.back-button:hover:not(:disabled) { background: white; color: var(--teal); box-shadow: var(--shadow-sm); }
.back-button:disabled { opacity: 0.38; cursor: not-allowed; }
.business-hub-title {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--navy);
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
}
.business-hub-mode .main-nav,
.business-hub-mode .topbar-right { display: none !important; }
.business-hub-mode .business-hub-title {
  display: block;
  position: static;
  order: 3;
  flex: 1 1 auto;
  min-width: 120px;
  transform: none;
  text-align: center;
}
.business-hub-mode .back-button { order: 4; }
.nav-tab {
  height: 32px;
  min-width: 112px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.nav-tab:hover { background: var(--surface); color: var(--navy); }
.nav-tab.is-active { background: var(--navy); color: white; box-shadow: 0 4px 10px rgba(18, 56, 79, 0.16); }
.topbar-right {
  margin-left: auto;
  padding-left: 10px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  border-left: 1px solid var(--line);
}
.topbar-right .btn {
  height: 38px;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.topbar-right .btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
#saveButton, #exportButton { min-width: 112px; }
.database-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 5px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.database-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal-bright); box-shadow: 0 0 0 4px rgba(19, 163, 160, 0.12); }
.database-status.is-offline i { background: var(--red); box-shadow: 0 0 0 4px rgba(181, 76, 76, 0.12); }
.database-status.is-local i { background: var(--amber); box-shadow: 0 0 0 4px rgba(201, 119, 49, 0.14); }

.btn {
  min-height: 39px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-quiet { background: rgba(255,255,255,0.75); }
.btn-primary { color: white; background: var(--teal); border-color: var(--teal); box-shadow: 0 6px 16px rgba(8, 127, 131, 0.18); }
.btn-primary:hover { background: #077477; }
.btn-full { width: 100%; background: var(--navy); color: white; border-color: var(--navy); }

.app-main { max-width: 1680px; margin: 0 auto; padding: 24px 28px 20px; }
.view { animation: none; }
.eyebrow { color: var(--teal); font-size: 9px; font-weight: 800; letter-spacing: 0.18em; }

.context-strip {
  min-height: 104px;
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 0.72fr)) minmax(250px, 1.1fr);
  background: rgba(255, 255, 252, 0.92);
  border: 1px solid rgba(20, 43, 56, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: visible;
}
.context-metric, .context-note { padding: 16px 20px; }
.context-customer label, .context-metric > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.field-note { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.field-note.is-unknown { color: var(--amber); }
.context-metric { border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.context-metric:first-child { border-left: 0; }
.context-metric > span { margin-bottom: 6px; }
.context-metric strong { color: var(--navy); font-size: 23px; line-height: 1; font-weight: 650; letter-spacing: -0.03em; }
.context-metric small { margin-top: 7px; color: var(--muted); font-size: 10px; }
.context-metric-wide strong { font-size: 17px; line-height: 1.3; }
.context-note {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(135deg, rgba(229, 246, 244, 0.7), rgba(255,255,255,0.15));
  border-radius: 0 var(--radius) var(--radius) 0;
}
.context-note p { color: var(--ink-soft); margin: 7px 0 0; font-size: 11px; line-height: 1.6; }

.workspace-grid { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; align-items: start; }
.workspace-grid.no-insight { grid-template-columns: minmax(0, 1fr); }
.quote-panel { min-width: 0; }
.quote-toolbar { display: flex; justify-content: space-between; align-items: flex-end; margin: 0 3px 10px; }
.quote-toolbar h1 { margin: 3px 0 0; color: var(--navy); font-size: 23px; letter-spacing: -0.03em; }
.quote-toolbar-actions { display: flex; align-items: center; gap: 7px; }
.preparer-chip { height: 34px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(8,127,131,0.22); border-radius: 8px; background: #eff9f7; color: var(--teal); cursor: pointer; }
.preparer-chip span { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 0.06em; }
.preparer-chip strong { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.preparer-chip:hover { background: #e5f6f3; border-color: rgba(8,127,131,0.38); }
.quote-language-switch { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,0.8); }
.quote-language-switch button { min-width: 34px; height: 24px; padding: 0 6px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 9px; font-weight: 700; cursor: pointer; }
.quote-language-switch button:hover { color: var(--teal); }
.quote-language-switch button.is-active { background: var(--navy); color: white; box-shadow: 0 2px 6px rgba(18,56,79,0.16); }
.autosave-status { color: var(--muted); font-size: 10px; margin-right: 4px; }
.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.78);
  border-radius: 8px;
  cursor: pointer;
}
.icon-button svg { width: 17px; height: 17px; }
.icon-button:hover { background: white; box-shadow: var(--shadow-sm); }

.quote-document {
  background: var(--paper);
  border: 1px solid rgba(20, 43, 56, 0.12);
  border-radius: 4px;
  box-shadow: 0 18px 45px rgba(21, 52, 64, 0.11);
  padding: 24px 28px 30px;
  position: relative;
  overflow: hidden;
}
.quote-document::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--navy), var(--teal) 56%, #85cbc6);
}
.document-head { min-height: 88px; display: flex; align-items: center; justify-content: flex-start; gap: 14px; }
.document-logo {
  position: absolute;
  left: 24px;
  top: 20px;
  width: 84px;
  height: 64px;
  color: var(--navy);
  display: grid;
  place-items: center;
}
.document-logo svg { width: 75px; height: 58px; }
.document-company { text-align: left; margin-left: 120px; padding-left: 0; }
.document-company span { display: block; color: #1f2933; font-family: "Avenir Next", "PingFang SC", sans-serif; font-size: 21px; font-weight: 500; letter-spacing: 0.1px; line-height: 1.28; }
.document-company small { display: block; margin-top: 5px; margin-left: 28px; color: #1f2933; font-family: "Avenir Next", "PingFang SC", sans-serif; font-size: 19px; font-weight: 500; letter-spacing: 0.02em; }
.document-company.is-zh span { font-size: 22px; font-weight: 600; }
.document-company.is-zh small { margin-left: 24px; font-size: 14px; }
.document-title-row {
  height: 44px;
  margin: 6px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  gap: 10px;
}
.document-title-row h2 { margin: 0; font-family: "Times New Roman", serif; font-size: 28px; letter-spacing: 0.14em; color: var(--navy); }
.document-title-row span { padding-left: 10px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: 10px; letter-spacing: 0.18em; }

.document-meta {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-bottom: 14px;
}
.meta-field {
  min-width: 0;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  min-height: 38px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: white;
}
.meta-field > span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.meta-field input, .meta-field select {
  width: 100%;
  min-width: 0;
  padding: 0 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 550;
}
.meta-field input:focus, .meta-field select:focus { background: #f3fbfa; box-shadow: inset 0 0 0 1px var(--teal); }
.meta-to { grid-column: span 2; }
.meta-date { grid-column: span 2; }
.meta-quote { grid-column: span 2; }
.meta-vessel { grid-column: span 4; }
.meta-currency { grid-column: span 2; }
.meta-subject { grid-column: span 6; }
.meta-field input::placeholder { color: #9babaF; font-weight: 400; }

.table-scroll { overflow-x: hidden; }
.quote-table, .history-table { width: 100%; border-collapse: collapse; }
.quote-table { table-layout: fixed; width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-collapse: collapse; }
.quote-table th {
  height: 35px;
  padding: 5px 6px;
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,0.15);
  color: white;
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-align: center;
}
.quote-table td {
  height: 45px;
  padding: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: white;
  vertical-align: middle;
}
.quote-table tbody { border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.quote-table th:last-child, .quote-table td:last-child { border-right: 1px solid var(--line-strong); }
.quote-table .col-item { width: 78px; }
.quote-table .col-desc { width: auto; }
.quote-table .col-unit { width: 52px; }
.quote-table .col-qty { width: 43px; }
.quote-table .col-price { width: 96px; }
.quote-table .col-amount { width: 88px; }
.quote-table .col-remarks { width: 132px; }
.quote-table input, .quote-table select, .quote-table textarea {
  width: 100%;
  height: 43px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  outline: 0;
  color: var(--ink);
  font-size: 10.5px;
}
.quote-table select { text-align: center; }
.quote-table input:focus, .quote-table select:focus, .quote-table textarea:focus { background: #f1faf9; box-shadow: inset 0 0 0 1px var(--teal); }
.quote-table textarea { display: block; min-height: 40px; padding: 8px 6px; border: 0; outline: 0; resize: none; overflow: hidden; line-height: 1.45; }

.quote-table .qty-input { text-align: center; }
.quote-table .remark-input { font-size: 9.5px; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.quote-table .remark-cell { padding: 2px; vertical-align: top; }

.quote-table .amount-cell { padding: 0 7px; text-align: right; font-family: var(--mono); font-size: 10px; color: var(--ink-soft); background: #fafcfc; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.desc-cell { position: relative; }
.desc-cell input { padding-right: 9px; }
.history-hint {
  display: none;
  margin: -3px 7px 5px;
  color: var(--teal);
  font-size: 8.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-hint.is-visible { display: block; }
.history-hint.is-none { color: var(--muted); }
.price-wrap { height: 43px; position: relative; display: flex; align-items: center; background: white; }
.price-wrap::before {
  content: "";
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
}
.price-wrap.is-matched::before { background: var(--teal-bright); }
.price-wrap input { padding: 0 27px 0 8px; text-align: right; font-family: var(--mono); font-size: 10px; }
.price-open {
  position: absolute;
  right: 1px;
  top: 5px;
  width: 24px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
}
.price-open svg { width: 12px; height: 12px; }
.price-open:hover, .price-open.is-active { background: var(--teal-pale); }
.remove-row {
  width: 100%;
  min-height: 43px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}
.remove-row:hover { color: #8f2f2f; background: #fff1ef; }
.remove-row span { display: block; transform: translateY(-1px); }
.group-row td { background: #eef4f4; border-top: 1px solid var(--line-strong); }
.subgroup-row td { background: #f7faf9; border-top: 1px solid var(--line); }
.quote-table tbody tr.is-context-row td { background: #eaf7f5; }
.quote-table tbody tr.is-context-row { box-shadow: inset 3px 0 0 var(--teal); }
.group-row .group-input, .subgroup-row .subgroup-input { height: 40px; padding: 0 10px; color: var(--navy); font-weight: 700; }
.group-row .group-input { font-size: 11.5px; }
.subgroup-row .subgroup-input { padding-left: 18px; font-size: 10.5px; color: var(--ink-soft); }
.row-leading { padding: 0 2px !important; background: #f8fbfa; text-align: center; white-space: nowrap; }
.row-number { display: inline-block; width: 40px; color: var(--navy); font-family: var(--mono); font-size: 9px; font-weight: 700; text-align: center; white-space: nowrap; vertical-align: middle; }
.item-no-input { display: inline-block !important; width: 42px !important; text-align: center !important; font-family: var(--mono) !important; font-size: 8.5px !important; color: var(--ink-soft) !important; vertical-align: middle; }
.row-leading .remove-row { display: inline-grid; width: 22px; min-height: 32px; font-size: 16px; color: #c34242; vertical-align: middle; }
.quote-table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 10px 2px 0; border-bottom: 1px solid var(--line); }
.text-button { height: 29px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--teal); cursor: pointer; font-size: 10px; font-weight: 650; }
.text-button:hover { background: var(--teal-pale); }
.text-button span { font-size: 14px; line-height: 1; }
.quote-table-actions p { margin-left: auto; color: var(--muted); font-size: 9px; }
.legend-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--teal-bright); }
.document-total {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
}
.document-total span { color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
.document-total b { color: var(--navy); }
.document-total strong { color: var(--navy); font-size: 17px; letter-spacing: -0.02em; }
.document-preparer { min-height: 34px; margin-top: 8px; padding: 7px 11px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 5px; background: #f7fbfa; color: var(--ink-soft); font-size: 9px; }
.document-preparer span { color: var(--muted); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.document-preparer strong { color: var(--ink); font-size: 11px; }
.document-preparer small { margin-left: auto; color: var(--muted); font-size: 8.5px; }
.document-approver { margin-top: 4px; }
.document-approver select { flex: 1; min-width: 0; height: 26px; padding: 0 7px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); font-size: 10px; font-weight: 600; outline: none; }
.document-approver select:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(8,127,131,0.08); }
.document-notes { padding: 12px 2px 0; color: var(--ink-soft); }
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.document-notes strong { display: block; color: var(--ink); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }
.notes-tools { display: flex; align-items: center; gap: 4px; }
.note-tool { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--teal); font-size: 8px; cursor: pointer; }
.note-tool:hover { background: var(--teal-pale); border-color: #afd9d5; }
#removeNoteButton { color: var(--muted); }
.notes-textarea {
  width: 100%;
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fcfefd;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 9px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
.notes-textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(8, 127, 131, 0.09); background: white; }
.notes-help { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }

.insight-panel {
  min-height: 620px;
  max-height: calc(100vh - 106px);
  position: sticky;
  top: 90px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.24) transparent;
  background: #102f41;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  color: white;
}
.insight-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 90% 0, rgba(48, 185, 179, 0.24), transparent 18rem),
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
}
.insight-empty { position: relative; padding: 44px 30px; }
.insight-empty-icon {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 15px;
  background: rgba(255,255,255,0.06);
  color: #6dd1cb;
}
.insight-empty-icon svg { width: 44px; height: 44px; }
.insight-empty .eyebrow { color: #65cfc9; }
.insight-empty h2 { margin: 10px 0 12px; font-size: 22px; line-height: 1.3; letter-spacing: -0.03em; }
.insight-empty > p { margin: 0; color: rgba(255,255,255,0.66); font-size: 12px; line-height: 1.75; }
.insight-empty ul { margin: 26px 0 0; padding: 0; list-style: none; border-top: 1px solid rgba(255,255,255,0.12); }
.insight-empty li { position: relative; padding: 13px 0 13px 21px; color: rgba(255,255,255,0.84); font-size: 11px; border-bottom: 1px solid rgba(255,255,255,0.09); }
.insight-empty li::before { content: ""; position: absolute; left: 2px; top: 18px; width: 7px; height: 7px; border: 1px solid #5bcfc9; border-radius: 50%; }
.insight-content { position: relative; padding: 24px 23px 28px; }
.insight-topline { display: flex; justify-content: space-between; align-items: center; }
.insight-topline .eyebrow { color: #69d3cc; }
.insight-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.scope-switch { display: flex; padding: 2px; border: 1px solid rgba(255,255,255,0.14); border-radius: 7px; background: rgba(0,0,0,0.12); }
.detail-mode-switch { border-color: rgba(102,222,214,0.32); }
.detail-mode-switch button { padding-inline: 9px; }
.priority-badge { padding: 5px 7px; border-radius: 5px; background: rgba(255,226,138,0.16); color: #ffe9ac; font-size: 9px; font-weight: 700; white-space: nowrap; }
.scope-switch button { padding: 6px 9px; border: 0; border-radius: 5px; background: transparent; color: rgba(255,255,255,0.76); font-size: 10.5px; font-weight: 650; cursor: pointer; white-space: nowrap; }
.scope-switch button.is-active { background: rgba(255,255,255,0.18); color: white; }
.insight-title { margin: 15px 0 7px; font-size: 21px; line-height: 1.3; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.insight-subtitle { color: rgba(255,255,255,0.78); font-size: 11.5px; line-height: 1.55; }
.insight-range-card { margin-top: 18px; padding: 16px; border: 1px solid rgba(255,255,255,0.12); border-radius: 11px; background: rgba(255,255,255,0.055); }
.range-caption { display: flex; justify-content: space-between; align-items: baseline; color: rgba(255,255,255,0.78); font-size: 10.5px; }
.range-caption strong { color: white; font-size: 22px; letter-spacing: -0.04em; }
.range-caption em { margin-left: 5px; color: #8ee3dd; font-style: normal; font-size: 10.5px; }
.range-summary { display: flex; flex-wrap: wrap; gap: 7px 15px; margin-top: 6px; color: rgba(255,255,255,0.74); font-size: 10px; }
.range-track { position: relative; height: 8px; margin: 22px 2px 9px; border-radius: 8px; background: rgba(255,255,255,0.12); }
.range-typical { position: absolute; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #1a8a8d, #59c7c1); opacity: 0.7; }
.range-marker { position: absolute; top: 50%; width: 14px; height: 14px; margin-left: -7px; transform: translateY(-50%); border: 3px solid #fff; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(201,119,49,0.28); }
.range-ticks { display: flex; justify-content: space-between; color: rgba(255,255,255,0.66); font-family: var(--mono); font-size: 9.5px; }
.position-readout { margin-top: 13px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,0.14); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.position-readout span { color: rgba(255,255,255,0.8); font-size: 10.5px; line-height: 1.45; }
.position-readout strong { color: #fff; font-size: 13px; white-space: nowrap; }
.position-pill { padding: 3px 7px; border-radius: 99px; font-style: normal; font-size: 8px; font-weight: 700; }
.position-pill.low { color: #9de4df; background: rgba(31,156,154,0.2); }
.position-pill.mid { color: #ffe0b2; background: rgba(201,119,49,0.22); }
.position-pill.high { color: #ffc8bd; background: rgba(207,83,63,0.22); }
.nearest-card { margin-top: 13px; padding: 13px 14px; border-left: 2px solid var(--teal-bright); background: rgba(0,0,0,0.12); }
.nearest-card span { display: block; color: rgba(255,255,255,0.72); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.nearest-card strong { display: block; margin-top: 5px; font-size: 13.5px; line-height: 1.5; }
.nearest-card small { display: block; margin-top: 4px; color: rgba(255,255,255,0.76); font-size: 10.5px; line-height: 1.45; }
.insight-section-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 9px; gap: 10px; }
.insight-section-head strong { font-size: 12.5px; }
.insight-section-head span { color: rgba(255,255,255,0.68); font-size: 9.5px; }
.sample-list { border-top: 1px solid rgba(255,255,255,0.11); }
.sample-row {
  width: 100%;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 3px;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.09);
  background: transparent;
  color: white;
  text-align: left;
  cursor: pointer;
}
.sample-row:hover { background: rgba(255,255,255,0.055); }
.sample-date { color: #7ee1da; font-family: var(--mono); font-size: 9.5px; line-height: 1.5; }
.sample-copy { min-width: 0; }
.sample-copy strong { display: block; color: #fff; white-space: normal; overflow-wrap: anywhere; font-size: 11px; line-height: 1.5; font-weight: 600; }
.sample-copy small { display: block; margin-top: 4px; color: rgba(255,255,255,0.68); font-size: 9.5px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.sample-price { font-family: var(--mono); font-size: 11px; font-weight: 650; text-align: right; line-height: 1.45; white-space: nowrap; }
.sample-price small { display: block; margin-top: 4px; color: rgba(255,255,255,0.64); font-size: 8.5px; font-weight: 400; }
.insight-empty-state { padding: 34px 22px; border: 1px dashed rgba(255,255,255,0.14); border-radius: 10px; color: rgba(255,255,255,0.58); font-size: 11px; line-height: 1.7; }
.insight-loading { padding: 42px 24px; }
.loading-line { height: 12px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.15), rgba(255,255,255,0.06)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.loading-line.short { width: 58%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.muted-caption { margin-top: 11px; color: rgba(255,255,255,0.6); font-size: 9.5px; line-height: 1.6; }
.name-record-section { margin-top: 18px; padding: 15px; border: 1px solid rgba(113,225,215,0.3); border-radius: 11px; background: rgba(14,123,126,0.18); }
.name-record-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.name-record-head strong { font-size: 13px; }
.name-record-head span { color: rgba(255,255,255,0.7); font-size: 9.5px; }
.name-record-list { border-top: 1px solid rgba(255,255,255,0.14); }
.name-record { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 2px; border: 0; border-bottom: 1px solid rgba(255,255,255,0.14); background: transparent; color: white; text-align: left; cursor: pointer; }
.name-record:hover { background: rgba(255,255,255,0.055); }
.name-record-main { flex: 1; min-width: 0; }
.name-record-main strong { display: block; color: #fff; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.name-record-main small { display: block; margin-top: 5px; color: rgba(255,255,255,0.68); font-size: 9.5px; line-height: 1.45; }
.name-record-action { flex: 0 0 auto; padding: 5px 7px; border: 1px solid rgba(102,222,214,0.45); border-radius: 5px; color: #8de5df; font-size: 8.5px; white-space: nowrap; }
.name-record-empty { margin-top: 16px; padding: 24px 18px; border: 1px dashed rgba(255,255,255,0.16); border-radius: 9px; color: rgba(255,255,255,0.7); font-size: 10px; line-height: 1.6; }
.keyword-section { margin-top: 17px; padding: 15px; border: 1px solid rgba(113,225,215,0.3); border-radius: 11px; background: rgba(14,123,126,0.2); }
.keyword-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.keyword-section-head strong { font-size: 13px; }
.keyword-section-head span { color: rgba(255,255,255,0.72); font-size: 9.5px; white-space: nowrap; }
.keyword-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.keyword-chip { padding: 3px 6px; border-radius: 5px; background: #5be0d5; color: #0c3341; font-family: var(--mono); font-size: 9.5px; font-weight: 700; }
.keyword-match-list { max-height: 370px; margin-top: 11px; overflow-y: auto; border-top: 1px solid rgba(255,255,255,0.16); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.28) transparent; }
.keyword-match { width: 100%; display: block; padding: 11px 2px; border: 0; border-bottom: 1px solid rgba(255,255,255,0.14); background: transparent; color: #fff; text-align: left; cursor: pointer; }
.keyword-match:hover { background: rgba(255,255,255,0.055); }
.keyword-match-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: #7ee1da; font-family: var(--mono); font-size: 9.5px; }
.keyword-match-meta span { color: rgba(255,255,255,0.68); font-family: var(--font); }
.keyword-match-text { display: block; margin-top: 6px; color: #fff; font-size: 11.5px; line-height: 1.62; white-space: normal; overflow-wrap: anywhere; }
.keyword-match-sub { display: block; margin-top: 5px; color: rgba(255,255,255,0.7); font-size: 9.5px; line-height: 1.55; white-space: normal; overflow-wrap: anywhere; }
.keyword-match-price { float: right; margin-left: 10px; color: #9cf0e9; font-family: var(--mono); font-size: 11px; font-weight: 700; }
.keyword-match mark, .sample-copy mark, .popover-sample mark { padding: 0 2px; border-radius: 3px; background: #ffe28a; color: #17323e; font-weight: 800; }
.keyword-empty { margin-top: 10px; color: rgba(255,255,255,0.7); font-size: 10px; line-height: 1.6; }

.price-popover {
  position: fixed;
  z-index: 90;
  width: 360px;
  max-width: calc(100vw - 24px);
  padding: 14px;
  background: #fff;
  border: 1px solid rgba(15, 47, 61, 0.16);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}
.popover-head { display: flex; justify-content: space-between; align-items: center; }
.popover-head strong { font-size: 12px; }
.popover-head span { color: var(--muted); font-size: 8px; }
.popover-range { display: flex; align-items: baseline; justify-content: space-between; margin-top: 12px; }
.popover-range strong { color: var(--navy); font-size: 19px; letter-spacing: -0.04em; }
.popover-range small { color: var(--muted); font-size: 8px; }
.popover-track { position: relative; height: 7px; margin: 14px 2px 8px; border-radius: 8px; background: #e4ebec; }
.popover-typical { position: absolute; height: 100%; border-radius: 8px; background: #8fd4ce; }
.popover-marker { position: absolute; top: 50%; width: 12px; height: 12px; margin-left: -6px; transform: translateY(-50%); border: 2px solid white; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px rgba(201,119,49,0.2); }
.popover-list { margin-top: 10px; max-height: 230px; overflow: auto; border-top: 1px solid var(--line); }
.popover-sample {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 9px 3px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.popover-sample:hover { background: var(--teal-pale); }
.popover-sample strong { display: block; font-size: 10.5px; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.popover-sample small { display: block; margin-top: 3px; color: var(--muted); font-size: 8.5px; line-height: 1.4; }
.popover-sample > span { color: var(--navy); font-family: var(--mono); font-size: 10px; font-weight: 700; text-align: right; }
.popover-foot { margin-top: 9px; color: var(--muted); font-size: 8px; display: flex; justify-content: space-between; }

.history-heading { display: flex; justify-content: space-between; align-items: flex-end; padding: 8px 3px 18px; }
.history-heading h1 { margin: 4px 0 5px; color: var(--navy); font-size: 28px; letter-spacing: -0.04em; }
.history-heading p { margin: 0; color: var(--ink-soft); font-size: 11px; }
.history-stats { display: flex; gap: 20px; color: var(--muted); font-size: 10px; }
.history-stats strong { color: var(--navy); font-size: 20px; margin-right: 4px; }
.history-filter-card {
  display: grid;
  grid-template-columns: 145px minmax(220px, 1fr) 180px 100px 160px 150px auto;
  gap: 10px;
  padding: 13px;
  background: rgba(255,255,252,0.9);
  border: 1px solid rgba(20, 43, 56, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.search-field { position: relative; }
.search-field svg { position: absolute; left: 13px; top: 12px; width: 17px; height: 17px; color: var(--muted); }
.search-field input { padding-left: 38px; }
.history-filter-card select { padding: 0 10px; font-weight: 500; }
.check-field { display: flex; align-items: center; gap: 7px; padding: 0 8px; color: var(--ink-soft); font-size: 10px; white-space: nowrap; }
.check-field input { accent-color: var(--teal); }
.history-layout { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.history-table-card { background: rgba(255,255,252,0.95); border: 1px solid rgba(20, 43, 56, 0.1); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.history-table { min-width: 1060px; }
.history-table th { padding: 11px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); color: var(--ink-soft); font-size: 8.5px; text-align: left; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.history-table td { padding: 10px; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: 9.5px; vertical-align: top; }
.history-table tr:last-child td { border-bottom: 0; }
.history-table tbody tr:hover td { background: #f6fbfa; }
.history-table tbody tr.history-quote-row { cursor: pointer; }
.history-table tbody tr.history-quote-row:hover td { background: #edf8f6; }
.history-table .num { text-align: right; }
.history-table .date-cell { color: var(--ink); font-family: var(--mono); font-size: 9px; white-space: nowrap; }
.history-table .customer-cell strong { display: block; color: var(--ink); font-size: 9.5px; }
.history-table .customer-cell small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.history-table .project-cell strong { display: block; max-width: 330px; color: var(--ink); font-size: 9.5px; line-height: 1.4; }
.history-table .project-cell small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.4; }
.history-table .quote-no { font-family: var(--mono); font-size: 8.5px; white-space: nowrap; }
.history-table .quote-no small { display: block; margin-top: 3px; color: var(--teal); font-family: var(--font); font-size: 7.5px; }
.history-table .price-cell { color: var(--navy); font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.history-table .source-cell { max-width: 160px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 8px; }
.history-table .preparer-cell { min-width: 90px; color: var(--ink); font-size: 8.5px; }
.history-table .preparer-cell small { display: block; margin-top: 3px; color: var(--muted); font-size: 7.5px; }
.history-view-only { color: var(--muted); font-size: 8px; white-space: nowrap; }
.history-locked-label { color: #a86a2b !important; font-weight: 700; }
.history-action { padding: 5px 9px; border: 1px solid #b9d7d5; border-radius: 6px; background: #effaf8; color: var(--teal); font-size: 8.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.history-action:hover { background: var(--teal); border-color: var(--teal); color: white; }
.empty-history { padding: 50px 20px; text-align: center; color: var(--muted); }
.data-note-card { padding: 22px; background: #12384f; border-radius: var(--radius); color: white; position: sticky; top: 90px; box-shadow: var(--shadow-md); }
.data-note-card .eyebrow { color: #66d1ca; }
.data-note-card h2 { margin: 9px 0 10px; font-size: 19px; line-height: 1.3; letter-spacing: -0.03em; }
.data-note-card > p { margin: 0; color: rgba(255,255,255,0.6); font-size: 10.5px; line-height: 1.7; }
.data-note-list { margin: 20px 0; border-top: 1px solid rgba(255,255,255,0.12); }
.data-note-list > div { display: grid; grid-template-columns: 28px 1fr; gap: 9px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.09); }
.data-note-list span { color: #67d2cc; font-family: var(--mono); font-size: 8px; }
.data-note-list p { margin: 0; color: rgba(255,255,255,0.6); font-size: 9.5px; line-height: 1.5; }
.data-note-list strong { display: block; margin-bottom: 2px; color: white; font-size: 10.5px; }

.app-footer { display: flex; justify-content: space-between; margin: 24px 2px 0; color: rgba(20,43,56,0.38); font-size: 8px; letter-spacing: 0.16em; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 120;
  min-width: 240px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 10px;
  background: #102f41;
  color: white;
  box-shadow: var(--shadow-lg);
  font-size: 11px;
  text-align: center;
  animation: toast-in 0.22s ease both;
}
.toast.is-error { background: #8c3f3f; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1380px) {
  .context-strip { grid-template-columns: repeat(3, minmax(150px, 0.7fr)); }
  .context-note { display: none; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 370px; }
}
@media (max-width: 1120px) {
  .topbar { gap: 14px; padding: 0 18px; }
  .brand { min-width: auto; }
  .database-status { display: none; }
  body:not(.business-hub-mode) .topbar {
    height: auto;
    min-height: 112px;
    padding: 10px 18px;
    flex-wrap: wrap;
    align-content: center;
    gap: 8px 10px;
  }
  body:not(.business-hub-mode) .brand { margin-right: auto; }
  body:not(.business-hub-mode) .main-nav { order: 5; }
  body:not(.business-hub-mode) .topbar-right { order: 6; }
  .app-main { padding: 18px; }
  .context-strip { grid-template-columns: repeat(2, minmax(140px, 0.6fr)); }
  .context-metric-wide { display: none; }
  .insight-empty { padding: 30px; }
  .insight-empty ul { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; }
  .insight-empty li { padding-right: 12px; }
  .history-layout { grid-template-columns: 1fr; }
  .data-note-card { position: relative; top: auto; }
}

/* Keep the history/price panel on the right for normal desktop and laptop
   windows. It only stacks underneath when the window is genuinely narrow. */
@media (max-width: 1120px) and (min-width: 901px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; }
}

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .insight-panel { position: relative; top: auto; min-height: 0; max-height: none; }
}
@media (max-width: 1120px) and (min-width: 761px) {
  .history-filter-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .history-filter-card .search-field { grid-column: span 2; }
}
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 66px; flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .brand-copy small { display: none; }
  body:not(.business-hub-mode) .main-nav { order: 5; width: auto; height: 40px; }
  body:not(.business-hub-mode) .nav-tab { flex: 0 0 auto; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn { min-height: 34px; padding: 0 9px; font-size: 10px; }
  .topbar-right .btn svg { display: none; }
  .app-main { padding: 12px; }
  .context-strip { grid-template-columns: 1fr 1fr; }
  .context-metric { padding: 12px 16px; border-top: 1px solid var(--line); }
  .context-metric:first-of-type { border-left: 0; }
  .quote-toolbar h1 { font-size: 20px; }
  .autosave-status { display: none; }
  .quote-document { padding: 18px 12px 22px; }
  .document-logo { left: 12px; width: 60px; }
  .document-logo svg { width: 55px; }
  .document-company { margin-left: 48px; padding-left: 0; }
  .document-company span { font-size: 14px; }
  .document-company small { font-size: 9px; }
  .document-company.is-zh span { font-size: 13px; }
  .document-title-row h2 { font-size: 24px; }
  .document-meta { grid-template-columns: 1fr 1fr; }
  .meta-to, .meta-subject { grid-column: span 2; }
  .meta-date, .meta-quote, .meta-vessel { grid-column: span 1; }
  .meta-currency { grid-column: span 2; }
  .meta-field { grid-template-columns: 70px minmax(0, 1fr); }
  .quote-table-actions p { display: none; }
  .document-total strong { font-size: 15px; }
  .document-preparer { align-items: flex-start; flex-wrap: wrap; }
  .document-preparer small { width: 100%; margin-left: 0; }
  .insight-empty ul { grid-template-columns: 1fr; }
  .history-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .history-filter-card { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: span 2; }
  .check-field { grid-column: span 2; }
  .price-popover { width: calc(100vw - 20px); }
}


.preparer-gate {
  position: fixed;
  z-index: 140;
  inset: 66px 0 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 25, 34, 0.68);
  backdrop-filter: blur(7px);
}
.preparer-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 18px;
  background: #fffefb;
  box-shadow: 0 32px 90px rgba(5, 20, 29, 0.38);
}
.preparer-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.preparer-dialog-head h2 { margin: 6px 0 0; color: var(--navy); font-size: 27px; letter-spacing: -0.04em; }
.preparer-dialog-mark { color: rgba(18,57,80,0.18); font-family: var(--mono); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; }
.preparer-step { padding-top: 22px; }
.preparer-intro { margin: 0 0 20px; color: var(--ink-soft); font-size: 12px; line-height: 1.7; }
.preparer-select-field { display: grid; gap: 8px; }
.preparer-select-field span,
.preparer-admin-add label span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.preparer-select-field select,
.preparer-admin-add input { width: 100%; height: 48px; padding: 0 13px; border: 1px solid rgba(15,47,61,0.18); border-radius: 9px; background: white; color: var(--ink); font-size: 14px; outline: none; }
.preparer-select-field select:focus,
.preparer-admin-add input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,131,0.1); }
.preparer-role-hint { min-height: 20px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.preparer-role-hint strong { color: var(--navy); }
.preparer-admin-auth { margin-top: 14px; padding: 13px; border: 1px solid rgba(8,127,131,0.24); border-radius: 9px; background: #eef9f7; }
.preparer-admin-auth label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 10px; font-weight: 700; }
.preparer-admin-auth > div { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.preparer-admin-auth #preparerPasswordConfirmWrap { display: block; margin-top: 8px; }
#preparerPasswordConfirm { width: 100%; }
.preparer-admin-auth input { height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: white; font-size: 13px; outline: none; }
.preparer-admin-auth input:focus { border-color: var(--teal); }
.preparer-admin-auth small { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; }
.preparer-step-actions { margin-top: 18px; display: flex; justify-content: space-between; gap: 10px; }
.preparer-selected-line { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 7px; background: #eaf7f5; color: var(--teal); font-size: 10px; }
.preparer-selected-line strong { color: var(--navy); font-size: 13px; }
.preparer-step h3 { margin: 20px 0 12px; color: var(--navy); font-size: 18px; }
.preparer-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preparer-choice-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.preparer-choice-group { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #f8fbfa; }
.preparer-choice-group-title { padding: 0 3px 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.preparer-choice-group .preparer-choice { min-height: 102px; background: white; }
.preparer-choice { min-height: 132px; padding: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbfa; color: var(--ink); text-align: left; cursor: pointer; }
.preparer-choice:hover { border-color: rgba(8,127,131,0.5); background: #eef9f7; transform: translateY(-1px); }
.preparer-choice > span { color: var(--teal); font-family: var(--mono); font-size: 10px; font-weight: 800; }
.preparer-choice strong { color: var(--navy); font-size: 18px; }
.preparer-choice small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.preparer-back-link { margin-top: 18px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; text-decoration: underline; }
.preparer-admin-add { display: grid; grid-template-columns: 1fr 150px auto; gap: 10px; align-items: end; }
.preparer-admin-add label { display: grid; gap: 8px; }
.preparer-admin-add select { height: 48px; padding: 0 10px; border: 1px solid rgba(15,47,61,0.18); border-radius: 9px; background: white; color: var(--ink); font-size: 12px; outline: none; }
.preparer-admin-add select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,131,0.1); }
.preparer-admin-list { margin-top: 18px; border-top: 1px solid var(--line); }
.preparer-admin-row { min-height: 54px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.preparer-admin-row strong { flex: 1; color: var(--ink); font-size: 12px; }
.preparer-admin-row span { padding: 3px 6px; border-radius: 4px; background: #e8f6f4; color: var(--teal); font-size: 8px; font-weight: 700; }
.preparer-admin-row span.is-inactive { background: #f1f1ee; color: var(--muted); }
.preparer-admin-row span.is-admin { background: #fff1d8; color: #9b6122; }
.preparer-admin-row .preparer-password { background: #f4f6f5; color: var(--ink-soft); font-family: var(--mono); letter-spacing: 0.02em; }
.preparer-admin-row button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink-soft); font-size: 9px; cursor: pointer; }
.preparer-admin-empty { padding: 22px 0; color: var(--muted); font-size: 11px; }
@media (max-width: 760px) {
  .preparer-dialog { padding: 20px 16px; }
  .preparer-dialog-head h2 { font-size: 23px; }
  .preparer-choice-grid { grid-template-columns: 1fr; }
  .preparer-choice-columns { grid-template-columns: 1fr; }
  .preparer-admin-add { grid-template-columns: 1fr; }
  .preparer-step-actions { flex-direction: column-reverse; }
  .document-preparer { align-items: flex-start; flex-wrap: wrap; }
  .document-preparer small { width: 100%; margin-left: 0; }
}

.delete-quote-gate {
  position: fixed;
  z-index: 150;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9,25,34,0.72);
  backdrop-filter: blur(7px);
}
.delete-quote-dialog {
  width: min(480px, calc(100vw - 28px));
  padding: 25px;
  border-radius: 16px;
  background: #fffefb;
  box-shadow: 0 30px 80px rgba(4,18,26,0.4);
}
.delete-quote-dialog h2 { margin: 7px 0 9px; color: var(--navy); font-size: 24px; }
.delete-quote-dialog p { margin: 0 0 18px; color: var(--ink-soft); font-size: 11px; line-height: 1.65; }
.delete-quote-dialog label { display: grid; gap: 8px; }
.delete-quote-dialog label span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.delete-quote-dialog input { height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.delete-quote-dialog input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,131,0.1); }
.delete-quote-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 9px; }
.delete-confirm { border-color: #a83b3b; background: #a83b3b; color: white; }
.history-actions { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.history-delete { border-color: rgba(168,59,59,0.28); color: #a83b3b; background: #fff8f7; }
.history-delete:hover { background: #fdeceb; }

.statistics-gate {
  position: fixed;
  z-index: 160;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 24, 34, 0.74);
  backdrop-filter: blur(8px);
}
.statistics-dialog {
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px;
  border: 1px solid rgba(255,255,255,0.62);
  border-radius: 18px;
  background: #f8fbfa;
  box-shadow: 0 32px 90px rgba(4,18,26,0.42);
}
.statistics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.statistics-head h2 { margin: 6px 0 5px; color: var(--navy); font-size: 27px; letter-spacing: -0.04em; }
.statistics-head p { margin: 0; max-width: 680px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.statistics-close {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.statistics-close:hover { color: var(--teal); border-color: rgba(8,127,131,0.4); }
.statistics-filter-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}
.statistics-filter-grid label { display: grid; gap: 7px; }
.statistics-filter-grid label span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.07em;
}
.statistics-filter-grid input,
.statistics-filter-grid select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid rgba(15,47,61,0.18);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 11px;
  outline: none;
}
.statistics-filter-grid input:focus,
.statistics-filter-grid select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,131,0.1); }
.statistics-toolbar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
#statisticsStatus { color: var(--muted); font-size: 10px; line-height: 1.5; }
.statistics-toolbar .btn { min-width: 112px; flex: 0 0 auto; }
.statistics-results { margin-top: 18px; }
.statistics-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.statistics-summary-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
}
.statistics-summary-card span { display: block; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0.06em; }
.statistics-summary-card strong { display: block; margin-top: 6px; color: var(--navy); font-size: 22px; line-height: 1; }
.statistics-summary-card strong.statistics-date-value { font-size: 16px; letter-spacing: -0.01em; }
.statistics-summary-card small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; }
.statistics-currency-summary { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.statistics-currency-chip {
  min-width: 150px;
  padding: 10px 13px;
  border: 1px solid rgba(8,127,131,0.2);
  border-radius: 9px;
  background: #eef8f6;
}
.statistics-currency-chip span { display: block; color: var(--muted); font-size: 9px; font-weight: 700; }
.statistics-currency-chip strong { display: block; margin-top: 4px; color: var(--navy); font-size: 16px; }
.statistics-currency-chip.is-warning { border-color: rgba(181,76,76,0.24); background: #fff7f5; }
.statistics-table-card { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.statistics-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.statistics-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #edf4f2;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: left;
}
.statistics-table th.num,
.statistics-table td.num { text-align: right; }
.statistics-table td { padding: 11px 12px; border-bottom: 1px solid rgba(24,59,74,0.08); color: var(--ink-soft); font-size: 11px; }
.statistics-table tbody tr:last-child td { border-bottom: 0; }
.statistics-table tbody tr:hover { background: #f6fbf9; }
.statistics-table td:first-child { color: var(--navy); font-weight: 700; }
.statistics-table.is-split th:last-child,
.statistics-table.is-split td:last-child { display: none; }
.statistics-table .statistics-empty { padding: 26px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
  .statistics-gate { padding: 12px; }
  .statistics-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); padding: 18px; }
  .statistics-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statistics-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .statistics-head { flex-direction: column; }
  .statistics-filter-grid { grid-template-columns: 1fr; }
  .statistics-toolbar { align-items: stretch; flex-direction: column; }
  .statistics-toolbar .btn { width: 100%; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: white; }
  .topbar, .context-strip, .quote-toolbar, .insight-panel, .quote-table-actions, .app-footer, .toast, .price-popover, .statistics-gate { display: none !important; }
  .app-main { max-width: none; padding: 0; }
  .workspace-grid { display: block; margin: 0; }
  .quote-document { padding: 0; border: 0; box-shadow: none; }
  .quote-document::before { display: none; }
  .quote-table { min-width: 0; }
  .quote-table input, .quote-table select, .quote-table textarea { appearance: none; }
  .notes-textarea { min-height: 0; overflow: hidden; border: 0; padding: 0; background: transparent; resize: none; }
  .notes-tools, .notes-help { display: none; }
  .history-table .source-cell { max-width: none; }
}

.preparer-admin-entry {
  margin-top: 14px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(8,127,131,0.34);
  border-radius: 8px;
  background: #eef9f7;
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.preparer-admin-entry:hover { background: #e2f5f2; }

.admin-search-import {
  margin-top: 20px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(8,127,131,0.22);
  border-radius: 12px;
  background: #f1faf8;
}
.admin-search-import h3 { margin: 5px 0 6px; color: var(--navy); font-size: 17px; }
.admin-search-import p { margin: 0; max-width: 500px; color: var(--ink-soft); font-size: 10px; line-height: 1.6; }
.admin-search-import small { display: block; margin-top: 8px; color: var(--teal); font-size: 9px; font-weight: 700; }
.admin-search-import .btn { flex: 0 0 auto; }
.admin-data-export {
  margin-top: 14px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfb;
}
.admin-data-export h3 { margin: 5px 0 6px; color: var(--navy); font-size: 17px; }
.admin-data-export p { margin: 0; max-width: 520px; color: var(--ink-soft); font-size: 10px; line-height: 1.6; }
.admin-data-export > div:last-child { display: flex; gap: 8px; flex: 0 0 auto; }
@media (max-width: 760px) {
  .admin-search-import { align-items: flex-start; flex-direction: column; }
  .admin-data-export { align-items: flex-start; flex-direction: column; }
}
