:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #17233a;
  --muted: #617087;
  --line: #dbe4f0;
  --green: #2f67b1;
  --green-dark: #164a92;
  --gold: #d9ad3d;
  --red: #bd5947;
  --soft-green: #eaf2fd;
  --soft-gold: #fbf3d8;
  --shadow: 0 18px 45px rgba(22, 74, 146, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1480px;
  background: var(--bg);
  color: var(--ink);
}

body.is-locked {
  min-width: 0;
  overflow: hidden;
}

body.is-locked .topbar,
body.is-locked .app-shell {
  display: none;
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.panel h2,
.quote-document h2 {
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand:hover h1,
.brand:focus-visible h1 {
  color: var(--green-dark);
}

body.is-new-quote-page .brand {
  cursor: default;
}

body.is-new-quote-page .brand:hover h1,
body.is-new-quote-page .brand:focus-visible h1 {
  color: inherit;
}

.brand-logo {
  width: 168px;
  height: auto;
  flex: 0 0 auto;
  display: block;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions,
.quote-actions,
.form-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 246, 251, 0.96)),
    radial-gradient(circle at 18% 18%, rgba(47, 103, 177, 0.16), transparent 34%),
    radial-gradient(circle at 78% 12%, rgba(217, 173, 61, 0.14), transparent 30%);
}

.login-view[hidden] {
  display: none;
}

.admin-login-link {
  position: fixed;
  top: 22px;
  right: 28px;
  color: var(--green-dark);
  background: #fff;
  border: 1px solid #c7d6ea;
  font-weight: 800;
}

.login-card {
  width: min(440px, calc(100vw - 48px));
  padding: 34px;
  background: #fff;
  border: 1px solid #c7d6ea;
  box-shadow: 0 24px 70px rgba(22, 74, 146, 0.16);
  text-align: center;
}

.login-logo {
  width: 190px;
  height: auto;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
}

.login-subtitle {
  margin: 10px 0 24px;
  color: var(--muted);
  font-weight: 700;
}

.login-panel {
  display: grid;
  gap: 12px;
  text-align: left;
}

.login-panel[hidden] {
  display: none;
}

.login-submit {
  width: 100%;
  justify-content: center;
  min-height: 42px;
}

.login-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.login-link-row button {
  padding: 0;
  color: var(--green-dark);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 800;
}

.login-link-row button:hover {
  text-decoration: underline;
}

.code-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 6px;
}

.code-input-row .ghost-btn {
  min-height: 36px;
  padding-inline: 10px;
}

.phone-code-line {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 230px;
  gap: 10px;
  align-items: end;
}

.phone-code-line > label {
  margin: 0;
}

.compact-code-row {
  grid-template-columns: minmax(104px, 1fr) auto;
}

.compact-code-row input {
  min-width: 0;
  text-align: center;
}

.login-error {
  margin: 0;
  padding: 9px 10px;
  color: var(--red);
  background: #fff3f0;
  border: 1px solid #e4c7c0;
  font-size: 13px;
  font-weight: 700;
}

.login-role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--green-dark);
  background: var(--soft-green);
  border: 1px solid #c7d6ea;
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  padding: 24px 32px 40px;
}

body.is-editing-quote .topbar,
body.is-editing-quote .tabs {
  display: none;
}

body.is-editing-quote .app-shell {
  padding-top: 18px;
}

.tabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.quote-edit-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  margin: -2px 0 18px;
  padding: 4px 0 4px 12px;
  border-left: 3px solid var(--green-dark);
  background: transparent;
}

.quote-edit-nav[hidden] {
  display: none;
}

.quote-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 10px 5px 8px;
  color: var(--green-dark);
  background: transparent;
  border-color: transparent;
  font-weight: 800;
}

.quote-back-btn:hover {
  color: var(--green-dark);
  background: rgba(22, 74, 146, 0.08);
  border-color: transparent;
}

.quote-back-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: inherit;
  background: rgba(22, 74, 146, 0.1);
  font-size: 20px;
  line-height: 1;
}

.quote-back-btn:hover .quote-back-icon {
  background: rgba(22, 74, 146, 0.16);
}

.quote-edit-path {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 32px;
}

.quote-edit-path strong {
  color: var(--green-dark);
  font-size: 15px;
}

.quote-path-separator {
  color: #a7b6c9;
  font-weight: 700;
}

.quote-edit-path #quoteEditPathName {
  min-width: 0;
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 146px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.tab-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.tab.is-active {
  background: var(--green-dark);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.sub-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.sub-tab {
  min-width: 128px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.sub-tab.is-active {
  color: #fff;
  background: var(--green-dark);
}

.library-panel {
  display: none;
}

.library-panel.is-active {
  display: block;
}

.quote-workspace {
  display: grid;
  grid-template-columns: 320px 320px minmax(760px, 1fr);
  gap: 16px;
  align-items: start;
}

.quote-workspace.is-selectors-collapsed {
  grid-template-columns: minmax(1180px, 1fr);
}

.quote-workspace.is-selectors-collapsed .selector-panel {
  display: none;
}

.selector-collapse-btn {
  position: fixed;
  left: 0;
  top: 50%;
  z-index: 40;
  display: grid;
  place-items: center;
  gap: 5px;
  width: 34px;
  min-height: 104px;
  padding: 8px 4px;
  color: #fff;
  background: var(--green-dark);
  border: 1px solid var(--green-dark);
  border-left: 0;
  box-shadow: 0 10px 24px rgba(22, 74, 146, 0.22);
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.selector-collapse-btn:hover {
  background: #0f3c78;
  border-color: #0f3c78;
}

.selector-collapse-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.selector-collapse-btn span {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0;
}

.quote-workspace.is-selectors-collapsed .selector-collapse-btn svg {
  transform: rotate(180deg);
}

.maintenance-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(560px, 1.1fr);
  gap: 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(380px, 0.72fr) minmax(680px, 1.28fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.selector-panel,
.quote-panel,
.maintenance-layout .panel,
.admin-card {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 20px;
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.current-quote-name {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 28px;
  width: 112px;
  padding: 0 10px;
  color: var(--green-dark);
  background: var(--soft-green);
  border: 1px solid #c8d8ee;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.price-pill {
  font-variant-numeric: tabular-nums;
}

#selectedProductCount,
#selectedCountryCount {
  color: #fff;
  background: #c9541d;
  border-color: #b84515;
  box-shadow: 0 6px 14px rgba(185, 69, 21, 0.2);
}

.toolbar {
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #ccd7d1;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 132px;
  line-height: 1.55;
  resize: vertical;
}

.backup-select {
  width: 150px;
  min-height: 38px;
  color: var(--green-dark);
  border-color: #c7d6ea;
  font-weight: 700;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(95, 143, 126, 0.16);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.primary-btn {
  color: #fff;
  background: var(--green-dark);
}

.ghost-btn,
.icon-btn {
  color: var(--green-dark);
  background: #fff;
  border-color: #c7d6ea;
}

.topbar-actions .ghost-btn:hover,
.topbar-actions .ghost-btn:focus-visible {
  color: #fff;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.danger-btn {
  color: #fff;
  background: var(--red);
}

.file-btn,
.import-library {
  position: relative;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.import-library {
  display: inline-flex;
}

.import-library > input {
  display: none;
}

.import-library-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 30;
  display: none;
  min-width: 240px;
  max-width: 360px;
  padding: 8px;
  background: #fff;
  border: 1px solid #c7d6ea;
  box-shadow: 0 18px 38px rgba(22, 74, 146, 0.16);
}

.import-library:hover .import-library-menu,
.import-library:focus-within .import-library-menu {
  display: block;
}

.import-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
}

.import-menu-item:hover {
  background: var(--soft-green);
  color: var(--green-dark);
}

.import-menu-item.is-empty {
  color: var(--muted);
  font-weight: 600;
}

.import-menu-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

button.import-menu-label {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.import-menu-text {
  display: inline-block;
  min-width: max-content;
  padding-right: 28px;
}

.import-menu-label.is-scrollable:hover .import-menu-text {
  animation: importNameMarquee 7s linear infinite;
}

@keyframes importNameMarquee {
  0%,
  14% {
    transform: translateX(0);
  }
  86%,
  100% {
    transform: translateX(var(--marquee-distance, -120px));
  }
}

.import-menu-delete {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.import-menu-delete:hover {
  color: #fff;
  background: var(--red);
}

.import-menu-divider {
  height: 1px;
  margin: 8px 0;
  background: var(--line);
}

.icon-btn {
  width: 42px;
  padding: 0;
}

.option-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  padding-right: 4px;
}

.option-card {
  border: 1px solid var(--line);
  background: #fff;
}

.option-card[open] {
  border-color: var(--green-dark);
  background: var(--soft-green);
  box-shadow: inset 4px 0 0 var(--green-dark);
}

.option-card[open] summary {
  background: #f7fbff;
}

.option-card summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px;
  list-style: none;
  cursor: pointer;
}

.option-card summary::-webkit-details-marker {
  display: none;
}

.option-card summary::before {
  content: "+";
  flex: 0 0 auto;
  width: 16px;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
}

.option-card[open] summary::before {
  content: "-";
}

.option-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.option-title strong,
.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-row .item-name {
  display: block;
  width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.option-title span,
.line-note {
  color: var(--muted);
  font-size: 12px;
}

.option-items {
  display: grid;
  gap: 1px;
  padding: 0 12px 12px;
}

.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  padding: 10px 0 12px;
  border-top: 1px solid #edf3fa;
}

.add-row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.line-price {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  color: #c9541d;
  font-size: 12px;
  overflow-wrap: anywhere;
  text-align: left;
}

.add-row-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.add-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.standard-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
  padding-right: 0;
}

.standard-chip {
  min-height: 24px;
  padding: 2px 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d4e0ee;
  font-size: 12px;
  font-weight: 700;
}

.standard-chip.is-selected {
  color: var(--green-dark);
  background: #fff;
  border-color: var(--green-dark);
}

.qty-input {
  width: 54px;
  min-height: 32px;
  padding: 4px 6px;
  text-align: center;
}

.add-btn {
  width: 34px;
  height: 32px;
  padding: 0;
  color: #fff;
  background: var(--green-dark);
  border: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.added-pill {
  justify-self: end;
  padding: 3px 8px;
  color: #fff;
  background: #9f2f24;
  border: 1px solid #8d271e;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(159, 47, 36, 0.18);
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8faf8;
  border: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.quote-document {
  padding: 28px;
  background: #fff;
  border: 1px solid #d4e0ee;
  border-radius: 10px;
  box-shadow: inset 0 4px 0 var(--green-dark);
  overflow: hidden;
}

.quote-table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.quote-title-row,
.totals {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.quote-title-row {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.quote-title-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.quote-logo {
  width: 138px;
  max-width: 28vw;
  height: auto;
  display: block;
}

.quote-title-brand h2 {
  font-size: 26px;
  letter-spacing: 0;
}

.quote-no {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  padding-top: 6px;
  font-weight: 700;
}

.quote-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.quote-meta div {
  min-height: 60px;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid #d4e0ee;
  border-radius: 8px;
}

.quote-meta div:last-child {
  border-right: 1px solid #d4e0ee;
}

.quote-meta dt {
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.quote-meta dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  min-height: 20px;
}

.quote-table {
  width: max(100%, 1420px);
  min-width: 1420px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.quote-table th,
.quote-table td {
  padding: 9px;
  border: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
}

.quote-table th {
  color: #fff;
  background: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.quote-table tbody tr:nth-child(even) {
  background: #f8fbff;
}

.quote-table tbody tr[draggable="true"] {
  cursor: grab;
}

.quote-table tbody tr[draggable="true"]:active {
  cursor: grabbing;
}

.quote-table tbody tr.is-dragging {
  opacity: 0.5;
}

.quote-table tbody tr.is-drop-target {
  outline: 3px solid rgba(47, 103, 177, 0.22);
  outline-offset: -3px;
}

.quote-table th:nth-child(1) {
  width: 106px;
}

.quote-table th:nth-child(2) {
  width: 108px;
}

.quote-table th:nth-child(3) {
  width: 82px;
}

.quote-table th:nth-child(4) {
  width: 150px;
}

.quote-table th:nth-child(5) {
  width: 170px;
}

.quote-table th:nth-child(6) {
  width: 116px;
}

.quote-table th:nth-child(7) {
  width: 120px;
}

.quote-table th:nth-child(8) {
  width: 58px;
}

.quote-table th:nth-child(9) {
  width: 118px;
}

.quote-table th:nth-child(10) {
  width: 92px;
}

.quote-table th:nth-child(11),
.quote-table th:nth-child(12) {
  width: 92px;
}

.thumb-cell {
  min-width: 64px;
  height: 64px;
  padding: 4px !important;
}

.thumb-cell:empty::after {
  content: "";
  display: inline-block;
  width: 54px;
  height: 54px;
  border: 1px dashed #c7d6ea;
  background: #f8fafc;
}

.thumb-cell img {
  max-width: 58px;
  max-height: 58px;
  object-fit: contain;
  vertical-align: middle;
}

.quote-table [contenteditable="true"],
.quote-meta [contenteditable="true"] {
  outline: none;
}

.quote-table [contenteditable="true"]:focus,
.quote-meta [contenteditable="true"]:focus {
  background: #fff8df;
  box-shadow: inset 0 0 0 2px rgba(217, 173, 61, 0.55);
}

.money {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.qty-col {
  text-align: center !important;
  font-variant-numeric: tabular-nums;
}

.quote-qty-control {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.quote-qty-input {
  width: 58px;
  min-height: 30px;
  padding: 4px 6px;
  text-align: center;
}

.quote-item-name {
  font-weight: 700;
}

.remove-line-btn {
  min-height: 26px;
  padding: 3px 8px;
  color: var(--red);
  background: #fff;
  border: 1px solid #e4c7c0;
  font-size: 12px;
  font-weight: 700;
}

.totals {
  align-items: stretch;
  margin-top: 16px;
  margin-left: auto;
  width: 420px;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.totals div {
  display: flex;
  justify-content: space-between;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.totals div:last-child {
  border-bottom: 0;
}

.totals .tax-rate-input {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  min-height: 26px;
  padding: 2px 3px;
  color: var(--ink);
  background: #fff;
  text-align: center;
}

.totals .tax-rate-input::-webkit-outer-spin-button,
.totals .tax-rate-input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.totals .tax-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.totals .total-with-tax {
  color: var(--ink);
  background: #fff;
}

.totals .total-with-tax strong {
  font-weight: 900;
}

.totals .discount-total {
  color: #fff;
  background: var(--red);
}

.totals #discountTotal {
  min-width: 88px;
  padding: 2px 6px;
  text-align: right;
  outline: none;
}

.totals #discountTotal:focus {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.notes {
  margin-top: 18px;
  padding: 14px;
  color: var(--muted);
  background: #f8fbff;
  border: 1px solid #d4e0ee;
  border-radius: 8px;
}

.notes p {
  margin: 6px 0 0;
  line-height: 1.7;
  outline: none;
  min-height: 28px;
}

.notes p:focus {
  background: #fff8df;
  box-shadow: inset 0 0 0 2px rgba(217, 173, 61, 0.55);
}

.notes strong {
  color: var(--green-dark);
  font-size: 13px;
}

.quote-save-bar {
  position: sticky;
  bottom: 18px;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.quote-save-bar .primary-btn {
  min-width: 128px;
  box-shadow: 0 14px 30px rgba(22, 74, 146, 0.18);
}

.records-panel {
  padding: 18px;
}

.record-toolbar {
  max-width: 560px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.record-pagination > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-pagination select {
  width: auto;
  min-height: 34px;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.record-row h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.record-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.record-owner {
  display: grid;
  gap: 4px;
  min-width: 88px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.record-owner strong {
  color: var(--ink);
  font-size: 14px;
}

.visibility-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
}

.visibility-badge.is-public {
  color: #fff;
  background: var(--green-dark);
  border: 1px solid var(--green-dark);
}

.visibility-badge.is-private {
  color: #526174;
  background: #f1f4f8;
  border: 1px solid #c7d6ea;
}

body.is-quote-readonly .quote-save-bar {
  display: none;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.security-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid #d4e0ee;
}

.security-status-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.security-status-row strong {
  color: var(--ink);
  font-size: 15px;
}

.link-btn {
  padding: 0;
  color: var(--green-dark);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: #c9541d;
}

.user-manage-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.user-row h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.user-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.editor-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
  background: #f8faf8;
  border: 1px solid var(--line);
}

.editor-form[hidden] {
  display: none;
}

#productDetailContent[hidden],
#countryDetailContent[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(31, 42, 39, 0.45);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-form:not([hidden]) {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 90;
  width: min(760px, calc(100vw - 56px));
  max-height: calc(100vh - 72px);
  overflow: auto;
  margin: 0;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 1px solid #c7d6ea;
  box-shadow: 0 28px 80px rgba(31, 42, 39, 0.28);
}

.editor-form .wide,
.form-actions {
  grid-column: 1 / -1;
}

.tag-editor-field {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  padding: 8px;
  background: #f8fbff;
  border: 1px solid #d4e0ee;
}

.editable-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 8px;
  color: var(--green-dark);
  background: #fff;
  border: 1px solid #c7d6ea;
  font-size: 12px;
  font-weight: 800;
}

.editable-tag button {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  color: var(--red);
  background: transparent;
  border: 0;
  font-size: 16px;
  line-height: 1;
}

.empty-tags {
  color: var(--muted);
  font-size: 12px;
}

.tag-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.manage-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 360px);
  overflow: auto;
  padding-right: 4px;
}

.manage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.library-group {
  border: 1px solid var(--line);
  background: #fff;
}

.sortable-group {
  cursor: grab;
}

.library-group.is-fixed-group .sortable-group {
  cursor: pointer;
}

.sortable-group:active {
  cursor: grabbing;
}

.library-group.is-fixed-group .sortable-group:active {
  cursor: pointer;
}

.library-group.is-dragging {
  opacity: 0.55;
}

.library-group.is-drop-target {
  border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(47, 103, 177, 0.14);
}

.library-group[open] {
  border-color: #c7d6ea;
}

.library-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--green-dark);
  background: #f8fbff;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.library-group > summary::-webkit-details-marker {
  display: none;
}

.library-group > summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #fff;
  background: var(--green-dark);
  font-weight: 900;
}

.library-group[open] > summary::before {
  content: "-";
}

.library-group-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-group-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.library-group-body {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.quote-option-group .library-group-body {
  padding: 8px;
}

.quote-option-group .option-card {
  border-color: #dbe4f0;
}

.manage-row h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.manage-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.library-price {
  color: #c9541d;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.selectable-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.sortable-row {
  cursor: grab;
}

.sortable-row:active {
  cursor: grabbing;
}

.sortable-row.is-dragging {
  opacity: 0.48;
}

.sortable-row.is-drop-target {
  border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(47, 103, 177, 0.14);
}

.list-select-main {
  display: grid;
  gap: 5px;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.list-select-main strong {
  color: var(--ink);
  font-size: 16px;
}

.list-select-main small {
  color: var(--muted);
  font-size: 13px;
}

.selectable-row.is-active {
  border-color: var(--green-dark);
  background: var(--soft-green);
  box-shadow: inset 4px 0 0 var(--green-dark);
}

.section-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  margin: 6px 0 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 5px 10px;
}

.icon-line-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--green-dark);
  background: #fff;
  border: 1px solid #c7d6ea;
}

.icon-line-btn:hover {
  color: #fff;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.icon-line-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-line-btn.danger-icon {
  color: var(--red);
  border-color: #e4c7c0;
}

.icon-line-btn.danger-icon:hover {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #c7d6ea;
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 35, 58, 0.38);
}

.app-dialog-overlay[hidden] {
  display: none;
}

.app-dialog {
  width: min(420px, calc(100vw - 48px));
  padding: 22px;
  background: #fff;
  border: 1px solid #c7d6ea;
  box-shadow: 0 26px 70px rgba(22, 74, 146, 0.22);
}

.app-dialog h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 18px;
}

.app-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    min-width: 0;
    background: #fff;
  }

  .topbar,
  .tabs,
  .sub-tabs,
  .selector-panel,
  .selector-collapse-btn,
  .client-grid,
  .quote-actions,
  .quote-save-bar,
  .quote-edit-nav,
  .records-panel,
  #adminTab,
  .quote-panel > .panel-heading,
  .remove-line-btn,
  .login-view,
  .login-role-badge,
  .app-dialog-overlay,
  .modal-overlay {
    display: none !important;
  }

  .app-shell,
  .quote-panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .quote-workspace {
    display: block;
  }

  .quote-document {
    width: calc(100% - 20mm);
    margin: 10mm;
    padding: 18px;
    background: #fff;
    border: 1px solid #d4e0ee;
    border-radius: 10px;
    box-shadow: inset 0 4px 0 var(--green-dark);
    overflow: visible;
  }

  .quote-table-scroll {
    width: 100%;
    padding: 0;
    overflow: visible;
  }

  .quote-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  }

  .quote-logo {
    width: 138px;
    max-width: 138px;
  }

  .quote-title-brand h2 {
    font-size: 24px;
  }

  .quote-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 14px 0;
  }

  .quote-meta div {
    min-height: 56px;
    padding: 10px;
    background: #f8fbff;
    border: 1px solid #d4e0ee;
    border-radius: 8px;
  }

  .quote-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 10.5px;
    margin: 0;
    page-break-inside: auto;
  }

  .quote-table th:nth-child(1) {
    width: 8.6%;
  }

  .quote-table th:nth-child(2) {
    width: 8.8%;
  }

  .quote-table th:nth-child(3) {
    width: 6.4%;
  }

  .quote-table th:nth-child(4) {
    width: 10.25%;
  }

  .quote-table th:nth-child(5) {
    width: 10.25%;
  }

  .quote-table th:nth-child(6) {
    width: 9.4%;
  }

  .quote-table th:nth-child(7) {
    width: 9.7%;
  }

  .quote-table th:nth-child(8) {
    width: 4.7%;
  }

  .quote-table th:nth-child(9) {
    width: 9.6%;
  }

  .quote-table th:nth-child(10),
  .quote-table th:nth-child(11),
  .quote-table th:nth-child(12) {
    width: 7.35%;
  }

  .quote-table th,
  .quote-table td {
    padding: 6px;
    border: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
  }

  .quote-table th {
    color: #fff;
    background: var(--green-dark);
  }

  .quote-table thead {
    display: table-row-group;
  }

  .quote-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .thumb-cell {
    height: 52px;
    padding: 3px !important;
  }

  .thumb-cell img {
    max-width: 48px;
    max-height: 48px;
  }

  .thumb-cell:empty::after {
    display: none;
  }

  .quote-qty-control {
    display: block;
  }

  .quote-qty-input {
    width: 42px;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: center;
  }

  .quote-qty-input::-webkit-outer-spin-button,
  .quote-qty-input::-webkit-inner-spin-button {
    appearance: none;
    margin: 0;
  }

  .totals {
    width: 420px;
    margin-top: 14px;
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
  }

  .totals div {
    display: flex;
    justify-content: space-between;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .totals .discount-total {
    color: #fff;
    background: var(--red);
  }

  .totals .tax-rate-input {
    border: 0;
    background: transparent;
    color: inherit;
  }

  .notes {
    margin-top: 14px;
    padding: 12px;
    color: var(--muted);
    background: #f8fbff;
    border: 1px solid #d4e0ee;
    border-radius: 8px;
  }
}
