/* ==========================================================================
   FS Peptide — quotation workspace
   ========================================================================== */

:root {
  --ink: #0d1220;
  --ink-2: #2b3244;
  --muted: #6b7385;
  --faint: #98a0b3;
  --line: #e5e7f0;
  --line-soft: #eef0f6;
  --bg: #f1f3f9;
  --surface: #ffffff;
  --violet: #5b21b6;
  --violet-2: #7c3aed;
  --violet-soft: #f5f2ff;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 10px 30px -12px rgba(16, 24, 40, .18), 0 2px 8px rgba(16, 24, 40, .04);
  --shadow-lg: 0 30px 70px -30px rgba(16, 24, 40, .35), 0 6px 20px rgba(16, 24, 40, .06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(124, 58, 237, .10), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(14, 116, 144, .08), transparent 55%);
  -webkit-font-smoothing: antialiased;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

::selection { background: rgba(124, 58, 237, .18); }

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(120deg, #0b0f1c 0%, #131a2e 55%, #1b1233 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 12px 30px -24px rgba(0, 0, 0, .9);
}

.topbar__inner {
  max-width: 1460px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

.brand__mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(124, 58, 237, .95), rgba(79, 70, 229, .7));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 6px 18px -8px rgba(124, 58, 237, .9);
  color: #fff;
  flex: none;
}
.brand__mark svg { width: 22px; height: 22px; fill: currentColor; }

.brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand__text strong { font-size: 14px; letter-spacing: .16em; font-weight: 700; white-space: nowrap; }
.brand__text small { color: #a9b0c6; font-size: 11px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.select--dark, .chip, .btn--ghost-dark, .iconbtn--dark {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #fff;
}

.select {
  appearance: none;
  border-radius: 9px;
  padding: 8px 30px 8px 12px;
  font: 600 12px/1 var(--font);
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 51%, calc(100% - 10px) 51%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select--dark option { color: var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 7px 13px 7px 10px;
  font: 600 12px/1 var(--font); cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.chip:hover { background: rgba(255, 255, 255, .12); }
.chip__icon { width: 14px; height: 14px; }
.chip.is-admin {
  background: rgba(124, 58, 237, .22);
  border-color: rgba(167, 139, 250, .55);
  color: #ede9fe;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 15px;
  font: 600 13px/1.2 var(--font);
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn__icon { width: 16px; height: 16px; }

.btn--primary {
  background: linear-gradient(135deg, var(--violet-2), var(--violet));
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(91, 33, 182, .85), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn--primary:hover { filter: brightness(1.06); }

.btn--soft {
  background: #f4f5fa;
  border-color: #e6e8f0;
  color: var(--ink-2);
}
.btn--soft:hover { background: #eceefa; border-color: #d9dcea; }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn--ghost:hover { background: #f6f7fb; }

.btn--ghost-dark { background: rgba(255, 255, 255, .06); color: #fff; border-color: rgba(255, 255, 255, .14); }
.btn--ghost-dark:hover { background: rgba(255, 255, 255, .13); }

.btn--danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn--danger:hover { background: #fef2f2; }

.btn--sm { padding: 7px 11px; font-size: 12px; border-radius: 8px; }
.btn--block { width: 100%; }

.iconbtn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { background: #f5f6fb; }
.iconbtn--dark { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: #fff; }
.iconbtn--dark:hover { background: rgba(255, 255, 255, .13); }

.mini {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 600 11px/1 var(--font);
  padding: 0 6px;
  transition: background .15s ease, color .15s ease;
}
.mini:hover { background: #f1f2f9; color: var(--violet); }
.mini svg { width: 13px; height: 13px; }

/* ---------------- workspace ---------------- */

.workspace {
  max-width: 1460px;
  margin: 0 auto;
  padding: 22px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

.canvas { min-width: 0; }

.docbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 10px;
  gap: 12px;
}
.docbar__status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .12);
}
.pulse.is-dirty { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }

/* ---------------- sheet ---------------- */

.sheet {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 34px 38px 30px;
  position: relative;
  overflow: hidden;
}
.sheet::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--violet), #4f46e5 45%, #0e7490);
}

.sheet__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.sheet__brand { display: flex; gap: 14px; align-items: center; }
.sheet__logo {
  width: 50px; height: 50px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--violet-2), var(--violet));
  color: #fff; font: 700 18px/1 var(--serif);
  letter-spacing: .02em;
  box-shadow: 0 10px 20px -12px rgba(91, 33, 182, .9);
}
.sheet__brand h1 {
  margin: 0;
  font: 600 25px/1.15 var(--serif);
  letter-spacing: .01em;
}
.sheet__brand p { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); letter-spacing: .03em; }

.sheet__doctitle { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.sheet__doctitle > span {
  font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--violet);
  font-weight: 700;
}
.sheet__doctitle strong { font: 600 19px/1.2 var(--font); letter-spacing: .01em; }
.sheet__doctitle .mini { margin-top: 1px; }

/* meta */

.meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 18px;
  padding: 20px 0 12px;
}

.meta__field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.meta__field--wide { grid-column: span 2; }
.meta__field > span:first-child {
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint);
}
.meta__field input, .meta__field select {
  width: 100%;
  border: 1px solid transparent;
  background: #f7f8fc;
  border-radius: 8px;
  padding: 8px 10px;
  font: 500 13px/1.2 var(--font);
  color: var(--ink);
  min-height: 36px;
}
.meta__field input:hover, .meta__field select:hover { background: #f2f4fa; }
.meta__field input:focus, .meta__field select:focus {
  outline: none; background: #fff; border-color: #c4b5fd;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.meta__inline { display: flex; gap: 6px; }
.meta__inline select { flex: 1 1 55%; min-width: 0; }
.meta__inline input[type="date"] { flex: 1 1 45%; min-width: 0; }
.is-hidden { display: none !important; }

/* rate bar */

.ratebar {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 0 0 8px;
  font-size: 11px; color: var(--faint);
}

/* items table */

.tablewrap { width: 100%; overflow-x: auto; }

.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.items thead th {
  font-size: 9.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfe;
  white-space: nowrap;
}
.items th.col-no, .items td.col-no { width: 34px; text-align: center; }
.items th.col-code, .items td.col-code { width: 96px; }
.items th.col-spec, .items td.col-spec { width: 112px; }
.items th.col-qty, .items td.col-qty { width: 74px; text-align: right; }
.items th.col-price, .items td.col-price { width: 116px; text-align: right; }
.items th.col-sub, .items td.col-sub { width: 112px; text-align: right; }
.items th.col-del, .items td.col-del { width: 34px; }

.items tbody tr { border-bottom: 1px solid var(--line-soft); }
.items tbody tr:hover { background: #fcfcff; }

.items td { padding: 7px 8px; vertical-align: middle; }
.items td.col-no { color: var(--faint); font-size: 12px; }
.items td.col-code { font-weight: 700; color: var(--violet); font-size: 12.5px; letter-spacing: .01em; }
.items td.col-name { font-weight: 500; }
.items td.col-spec { color: var(--muted); font-size: 12.5px; }
.items td.col-sub { font-weight: 600; font-variant-numeric: tabular-nums; }

.cell-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 5px 6px;
  font: 500 13px/1.2 var(--font);
  color: inherit;
  text-align: inherit;
}
.cell-input:focus { outline: none; background: #fff; border-color: #c4b5fd; box-shadow: 0 0 0 3px rgba(124, 58, 237, .1); }
.cell-input--num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-input[readonly] { color: var(--ink-2); cursor: default; }
.cell-input[readonly]:focus { background: transparent; border-color: transparent; box-shadow: none; }

.pricecell { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.pricecell svg { width: 11px; height: 11px; color: #c0c5d1; flex: none; }
.th-cur { font-style: normal; font-weight: 700; color: var(--violet); margin-left: 4px; }

.delbtn {
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center;
  border: 1px solid transparent; background: transparent;
  color: #b7bdcb; cursor: pointer; padding: 0;
}
.delbtn:hover { background: #fef2f2; color: var(--danger); border-color: #fee2e2; }
.delbtn svg { width: 14px; height: 14px; }

.emptyrow td { padding: 36px 12px !important; text-align: center; border-bottom: 1px solid var(--line-soft) !important; }
.emptyrow strong { display: block; font: 600 15px/1.3 var(--serif); margin-bottom: 4px; }
.emptyrow span { color: var(--muted); font-size: 12.5px; }
.emptyrow .btn { margin-top: 12px; }

/* sheet foot */

.sheet__foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 34px;
  padding: 22px 0 6px;
}

.notes { display: flex; flex-direction: column; gap: 6px; }
.notes__label {
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.notes textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fbfbfe;
  padding: 10px 12px;
  font: 400 12.5px/1.6 var(--font);
  color: var(--ink-2);
}
.notes textarea:focus { outline: none; border-color: #c4b5fd; background: #fff; box-shadow: 0 0 0 3px rgba(124, 58, 237, .1); }

.totals { display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.totals__row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 5px 0;
  font-size: 13px; color: var(--muted);
}
.totals__row b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.totals__row--input label { font-size: 12.5px; }

.moneyinput {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fbfbfe; border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 4px 8px; width: 132px; justify-content: flex-end;
}
.moneyinput .cur-sym { color: var(--faint); font-style: normal; font-size: 12px; }
.moneyinput input {
  width: 100%; border: 0; background: transparent; text-align: right;
  font: 600 13px/1.2 var(--font); color: var(--ink); padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.moneyinput input:focus { outline: none; }
.moneyinput:focus-within { border-color: #c4b5fd; background: #fff; box-shadow: 0 0 0 3px rgba(124, 58, 237, .1); }

.totals__row--grand {
  margin-top: 4px; padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase; font-weight: 700; color: var(--ink-2);
}
.totals__row--grand b { font: 700 22px/1.1 var(--font); color: var(--violet); }
.totals__units { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); }
.totals__note { margin: 7px 0 0; font-size: 10px; line-height: 1.5; color: var(--faint); text-align: right; }

/* terms */

.sheet__terms { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.sheet__contact { font-size: 10.5px; color: var(--muted); margin: 0 0 8px !important; letter-spacing: .02em; }
.sheet__terms p { margin: 0; font-size: 10.5px; line-height: 1.65; color: var(--muted); max-width: 92%; }
.signatures { display: flex; gap: 60px; margin: 26px 0 12px; }
.signatures > div { flex: 1; max-width: 260px; }
.signatures span { display: block; border-top: 1px solid #c9ceda; padding-top: 6px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.sheet__fine { text-align: center; font-size: 9.5px !important; color: var(--faint) !important; letter-spacing: .04em; }

/* ---------------- rail ---------------- */

.rail {
  position: sticky; top: 82px;
  display: flex; flex-direction: column; gap: 14px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 15px;
}
.card--actions { display: flex; flex-direction: column; gap: 9px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 .btn { padding: 9px 8px; font-size: 12px; }

.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card__head h2 {
  margin: 0; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.card__head .mini { width: auto; padding: 4px 7px; white-space: nowrap; }

.hint { font-size: 11.5px; line-height: 1.55; color: var(--muted); margin: 2px 0 0; }
.hint--tiny { font-size: 10.5px; color: var(--faint); }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.history__item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 8px 9px;
  background: #fcfcff;
  transition: border-color .15s ease, background .15s ease;
}
.history__item:hover { border-color: #ddd6fe; background: #faf8ff; }
.history__open {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit;
}
.history__no { font-size: 11px; font-weight: 700; color: var(--violet); letter-spacing: .02em; }
.history__meta { font-size: 10.5px; color: var(--faint); display: flex; justify-content: space-between; gap: 8px; }
.history__meta b { color: var(--ink-2); font-weight: 600; }
.history__del {
  border: 0; background: transparent; color: #c3c8d4; cursor: pointer; padding: 4px; border-radius: 5px;
  display: grid; place-items: center;
}
.history__del:hover { background: #fef2f2; color: var(--danger); }
.history__del svg { width: 13px; height: 13px; }
.history__empty { font-size: 11.5px; color: var(--faint); padding: 14px 6px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

/* ---------------- modals ---------------- */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(9, 11, 20, .55);
  backdrop-filter: blur(3px);
  animation: fade .18s ease both;
}
.modal__panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  display: flex; flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .55);
  overflow: hidden;
  animation: pop .2s cubic-bezier(.2, .8, .3, 1) both;
}
.modal__panel--sm { width: min(430px, 100%); }
.modal__panel--xs { width: min(400px, 100%); }
.modal__panel--lg { width: min(980px, 100%); }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }

.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal__head h2 { margin: 0; font: 600 18px/1.2 var(--serif); }
.modal__toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 20px 0; }
.modal__toolbar--wrap { flex-wrap: wrap; }
.modal__body { padding: 16px 20px 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal__body--image { display: flex; flex-direction: column; align-items: center; gap: 10px; background: #f6f7fb; }
.modal__body--image img { max-width: 100%; max-height: 62vh; border-radius: 8px; box-shadow: var(--shadow-md); background: #fff; }
.modal__foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
  background: #fcfcfe;
}
.modal__foot .hint { margin-right: auto; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field--wide { grid-column: 1 / -1; }
.field input, .field select, .input, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 9px 11px;
  font: 500 13px/1.3 var(--font);
  color: var(--ink);
}
.field input:focus, .field select:focus, .input:focus, .textarea:focus {
  outline: none; border-color: #c4b5fd; box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.input--grow { flex: 1 1 220px; }
.textarea { resize: vertical; font-family: var(--font); line-height: 1.6; }
.textarea, .input { margin-top: 8px; }
.modal__toolbar .input { margin-top: 0; }

.readonly-note { font-size: 11px; color: var(--faint); }

.formerror { color: var(--danger); font-size: 12px; margin: 8px 0 0; }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.modal .grid2, .modal .grid3 { gap: 0 14px; }

/* picker */

.chips { display: flex; gap: 7px; flex-wrap: wrap; padding: 12px 20px 0; }
.chips--sub { padding-top: 8px; }
.chips--sub .chipbtn { font-size: 10.5px; padding: 5px 10px; background: #faf9ff; }
.chipbtn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font: 600 11.5px/1 var(--font);
  color: var(--muted);
  cursor: pointer;
}
.chipbtn:hover { border-color: #ddd6fe; color: var(--violet); }
.chipbtn.is-active { background: var(--violet); border-color: var(--violet); color: #fff; }

.tag-new {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-radius: 4px;
  padding: 2px 5px;
  margin-left: 5px;
  vertical-align: middle;
  line-height: 1.1;
}
.lib-name { display: flex; flex-wrap: wrap; align-items: center; }

.picker__group { border-bottom: 1px solid var(--line-soft); padding: 12px 0; }
.picker__group:last-child { border-bottom: 0; }
.picker__top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.picker__name { font-weight: 600; font-size: 14px; }
.picker__code { font-size: 11px; font-weight: 700; color: var(--violet); letter-spacing: .04em; }
.picker__cat { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.picker__specs { display: flex; flex-wrap: wrap; gap: 7px; }
.specbtn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: #fcfcff;
  border-radius: 9px;
  padding: 7px 11px;
  cursor: pointer;
  font: 600 12px/1 var(--font);
  color: var(--ink-2);
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.specbtn:hover { border-color: #c4b5fd; background: var(--violet-soft); transform: translateY(-1px); }
.specbtn small { font-weight: 500; color: var(--muted); font-size: 11px; }
.specbtn:hover small { color: var(--violet); }
.picker__empty, .empty { text-align: center; color: var(--faint); font-size: 12.5px; padding: 40px 10px; }

/* library */

.libtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.libtable th {
  text-align: left; font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint); padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.libtable td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.libtable td.code { font-weight: 700; color: var(--violet); white-space: nowrap; }
.libtable td.actions { white-space: nowrap; text-align: right; }
.libtable .mini { width: auto; padding: 5px 8px; font-size: 11px; }
.libtable .mini--danger:hover { background: #fef2f2; color: var(--danger); }

.specs-list { display: flex; flex-wrap: wrap; gap: 4px; }
.specpill {
  font-size: 10.5px; color: var(--ink-2); background: #f4f5fa; border-radius: 5px; padding: 2px 6px;
}
.specpill em { font-style: normal; color: var(--faint); margin-left: 4px; }

.libform { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 6px; }
.libform h3 { margin: 0 0 14px; font: 600 15px/1.2 var(--serif); }

.specrows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.specrow { display: grid; grid-template-columns: minmax(0, 1fr) 150px 38px; gap: 8px; align-items: center; }
.specrow input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 500 13px/1.2 var(--font); }
.specrow input:focus { outline: none; border-color: #c4b5fd; box-shadow: 0 0 0 3px rgba(124, 58, 237, .1); }
.specrow .delbtn { justify-self: end; }

.rowend { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* settings */

.settings__section { padding: 4px 0 18px; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; }
.settings__section:last-child { border-bottom: 0; margin-bottom: 0; }
.settings__section h3 {
  margin: 0 0 10px; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
}
.settings__section .grid2, .settings__section .grid3 { margin-top: 6px; }

.rates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rates .field { margin-bottom: 0; }
.rates .field span { font-size: 10.5px; }

.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12.5px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--violet); }

.summary {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; font-size: 11.5px;
}
.summary span { background: var(--violet-soft); color: var(--violet); border-radius: 999px; padding: 4px 10px; font-weight: 600; }

.tablewrap--short { max-height: 260px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 10px; }
.errors { margin: 10px 0 0; padding: 0; list-style: none; font-size: 11.5px; color: var(--danger); max-height: 120px; overflow-y: auto; }

/* parse results */

.parsed { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.parsed li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: #fbfbfe; border: 1px solid var(--line-soft); }
.parsed li.is-bad { background: #fff7f7; border-color: #fee2e2; color: #b42318; }
.parsed b { color: var(--violet); font-size: 11.5px; min-width: 58px; }
.parsed span { color: var(--muted); }
.parsed em { margin-left: auto; font-style: normal; font-weight: 600; color: var(--ink-2); }

/* toasts */

.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #111827; color: #fff; border-radius: 10px; padding: 9px 16px;
  font: 500 12.5px/1.3 var(--font); box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .6);
  animation: toastIn .2s ease both;
}
.toast--error { background: #b42318; }
.toast--ok { background: #065f46; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ---------------- responsive ---------------- */

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 290px; }
  .sheet { padding: 28px 26px 24px; }
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
  .card--actions .grid2 { grid-template-columns: repeat(4, 1fr); }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar__inner { padding: 10px 14px; gap: 10px; }
  .brand__text small { display: none; }
  .workspace { padding: 14px 12px 48px; }
  .sheet { padding: 22px 16px 18px; border-radius: 14px; }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet__foot { grid-template-columns: 1fr; gap: 20px; }
  .sheet__head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .sheet__doctitle { align-items: flex-start; text-align: left; }

  .items { min-width: 0; }
  .items thead { display: none; }
  .items, .items tbody, .items td { display: block; width: auto; }
  .items tbody tr {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 40px 11px 13px;
    margin-bottom: 10px;
    background: #fff;
  }
  .items tbody tr:hover { background: #fff; }
  .items td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 3px 0 !important;
    border: 0 !important;
    text-align: left;
    width: 100% !important;
  }
  .items td::before {
    content: attr(data-label);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--faint);
    white-space: nowrap;
    flex: none;
  }
  .items td.col-no { display: none; }
  .items td.col-name { order: 0; display: block; font-size: 15px; font-weight: 600; }
  .items td.col-name::before { content: none; }
  .items td.col-code { order: 1; font-size: 11px; }
  .items td.col-spec { order: 2; }
  .items td.col-qty { order: 3; }
  .items td.col-price { order: 4; }
  .items td.col-sub { order: 5; font-size: 14px; font-weight: 700; padding-top: 6px !important; }
  .items td.col-qty .cell-input,
  .items td.col-price .cell-input {
    width: 108px;
    text-align: right;
    background: #f7f8fc;
    border-color: transparent;
    padding: 6px 8px;
  }
  .items td.col-del { position: absolute; top: 8px; right: 7px; padding: 0 !important; width: auto !important; }
  .items td.col-del::before { content: none; }
  .items .emptyrow td { display: block; text-align: center; padding: 22px 10px !important; }
  .items .emptyrow td::before { content: none; }
  .items .emptyrow .btn { margin-top: 10px; }

  .card--actions .grid2 { grid-template-columns: repeat(2, 1fr); }
  .grid3, .grid2 { grid-template-columns: 1fr; }
  .rates { grid-template-columns: repeat(2, 1fr); }
  .modal { padding: 10px; }
  .modal__panel { max-height: 94vh; border-radius: 14px; }
  .signatures { flex-direction: column; gap: 22px; }
  .sheet__terms p { max-width: 100%; }
}

@media (max-width: 620px) {
  .brand__text { display: none; }
  .topbar__actions { gap: 6px; }
  #btnLibrary span { display: none; }
  #btnLibrary { padding: 9px 10px; }
}

@media (max-width: 520px) {
  .topbar__actions { gap: 5px; }
  .chip span { display: none; }
  .chip { padding: 8px; }
}

/* ---------------- print ---------------- */

@media print {
  @page { size: A4; margin: 10mm; }

  html, body {
    background: #fff !important;
    font-size: 10pt;
  }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .topbar, .rail, .docbar, .modal, .toasts, .no-print, .ratebar, .col-del, .delbtn { display: none !important; }

  .workspace { display: block; padding: 0; margin: 0; max-width: none; }
  .canvas { display: block; }

  .sheet {
    box-shadow: none !important;
    border: 0;
    border-radius: 0;
    padding: 0;
    overflow: visible;
  }
  .sheet::before { display: none; }

  .sheet__head { padding-bottom: 12px; }
  .sheet__logo { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet__brand h1 { font-size: 19pt; }
  .sheet__doctitle strong { font-size: 13pt; }

  .items { font-size: 9pt; }
  .items thead { display: table-header-group; }
  .tablewrap { overflow: visible; }
  .items { display: table; width: 100%; min-width: 0; table-layout: fixed; }
  .items tbody { display: table-row-group; }
  .items tbody tr { display: table-row; position: static; border: 0; border-radius: 0; padding: 0; margin: 0; background: transparent; }
  .items td { display: table-cell; width: auto; padding: 7px 6px !important; border-bottom: 1px solid #eef0f6 !important; text-align: left; }
  .items td::before { content: none !important; }
  .items th.col-no, .items td.col-no { width: 4% !important; }
  .items th.col-code, .items td.col-code { width: 11% !important; }
  .items th.col-name, .items td.col-name { width: 30% !important; }
  .items th.col-spec, .items td.col-spec { width: 18% !important; }
  .items th.col-qty, .items td.col-qty { width: 7% !important; }
  .items th.col-price, .items td.col-price { width: 14% !important; }
  .items th.col-sub, .items td.col-sub { width: 16% !important; }
  .items td.col-no, .items td.col-code, .items td.col-name, .items td.col-spec,
  .items td.col-qty, .items td.col-price, .items td.col-sub { display: table-cell !important; }
  .items td.col-del { display: none !important; }
  .items td.col-qty, .items td.col-price, .items td.col-sub { text-align: right; }
  .items td.col-name, .items td.col-sub { font-size: 9pt; }
  .items td.col-qty .cell-input, .items td.col-price .cell-input {
    width: auto; background: transparent !important; border: 0 !important; padding: 0 !important; text-align: right;
  }
  .items thead th { background: #f4f1ff !important; padding: 6px 6px; font-size: 7pt; }
  .items th.col-no { width: 4%; }
  .items th.col-code { width: 11%; }
  .items th.col-name { width: 30%; }
  .items th.col-spec { width: 18%; }
  .items th.col-qty { width: 7%; }
  .items th.col-price { width: 14%; }
  .items th.col-sub { width: 16%; }
  .items tbody tr { break-inside: avoid; page-break-inside: avoid; }
  .items td { padding: 7px 6px; }

  .meta { padding: 12px 0 8px; gap: 10px 16px; }
  .meta__field > span:first-child { font-size: 7pt; }
  .meta__field input, .meta__field select,
  .notes textarea, .moneyinput, .moneyinput input, .cell-input {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-size: 9pt;
    color: #000 !important;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 0;
  }
  .meta__field input[type="date"]::-webkit-calendar-picker-indicator { display: none; }
  .notes textarea { min-height: 0; height: auto; resize: none; overflow: hidden; }
  .moneyinput { width: 96px; justify-content: flex-start; gap: 3px; }
  .moneyinput input { width: 64px; text-align: left; }
  .moneyinput .cur-sym { color: #555; }
  .notes.is-empty { display: none; }

  .sheet__foot { gap: 20px; grid-template-columns: minmax(0, 1fr) 250px; padding-top: 12px; break-inside: avoid; page-break-inside: avoid; }
  .totals__row--grand b { font-size: 14pt; color: #3b0f7a; }
  .sheet__terms { margin-top: 8px; padding-top: 10px; break-inside: avoid; page-break-inside: avoid; }
  input::placeholder, textarea::placeholder { color: transparent !important; opacity: 0 !important; }
  .sheet__terms p { font-size: 7.5pt; max-width: 100%; }
  .totals { break-inside: avoid; page-break-inside: avoid; }
  .signatures { flex-direction: row; gap: 60px; margin: 22px 0 10px; break-inside: avoid; }
  .signatures > div { flex: 1; max-width: 260px; }
  .sheet__fine { font-size: 7pt !important; }
  .emptyrow { display: none; }
}
