/* Витрина — «аптекарский леджер»: бумага, чернила, один зелёный акцент.
   Серифные заголовки, hairline-линии, цены табличными цифрами. */

:root {
  --paper: #f7f4ee;
  --paper2: #efebe2;
  --ink: #23201a;
  --muted: #8b8577;
  --line: #e0d9cb;
  --line-strong: #cfc7b6;
  --green: #2f6b4f;
  --green-soft: color-mix(in srgb, var(--green) 10%, var(--paper));
  --red: #a3403b;
  --amber: #a07724;
  --steel: #55677e;
  --violet: #6d5e93;
  --gray: #85806f;

  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  --sans: -apple-system, system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* тёмная тема (Telegram dark) */
.dark {
  --paper: #16151a;
  --paper2: #1e1d23;
  --ink: #ece9e1;
  --muted: #98917f;
  --line: #2c2a31;
  --line-strong: #3a3840;
  --green: #5ea282;
  --green-soft: color-mix(in srgb, var(--green) 12%, var(--paper));
  --red: #cf7a72;
  --amber: #cfa14e;
  --steel: #8296ae;
  --violet: #a495c9;
  --gray: #918b7c;
}

html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper); color: var(--ink);
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; color: inherit; }
.hidden { display: none !important; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding-bottom: 92px; }

h1, .brand, .price-lg, .inv-amount, .oc-total, .total-row b { font-family: var(--serif); }

/* ============ шапка каталога ============ */
.topbar {
  padding: calc(env(safe-area-inset-top) + 16px) 20px 12px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(var(--paper) 80%, transparent);
}
.brand-row { margin-bottom: 13px; }
.brand {
  font-size: 30px; line-height: 1; letter-spacing: .02em;
  border-bottom: 2px solid var(--ink); display: inline-block; padding-bottom: 6px;
}
.brand-note { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; margin-top: 7px; }

.searchline {
  display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid var(--line-strong); padding: 7px 2px;
}
.searchline:focus-within { border-color: var(--ink); }
.searchline .ic { width: 17px; height: 17px; color: var(--muted); flex: none; }
#search {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: var(--ink); font-size: 15px; font-family: inherit; padding: 0;
}
#search::placeholder { color: var(--muted); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.tabs { display: flex; gap: 22px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: none; cursor: pointer; padding: 6px 1px 8px;
  font-size: 13.5px; font-weight: 600; letter-spacing: .04em; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab i { font-style: normal; font-size: 10.5px; vertical-align: super; opacity: .75; margin-left: 2px; }
.tab.on { color: var(--ink); border-color: var(--ink); }
.tab:active { transform: translateY(1px); }

/* ============ список товаров ============ */
.list { padding: 6px 20px; }
.prow {
  padding: 13px 0; display: flex; align-items: baseline; gap: 12px;
  border-bottom: 1px solid var(--line);
  animation: fadein .25s ease both;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.mono {
  flex: none; width: 30px; height: 30px; align-self: center;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); color: var(--muted);
  font-family: var(--serif); font-style: italic; font-size: 12px; letter-spacing: .03em;
}
.pinfo { min-width: 0; }
.pname { font-weight: 600; font-size: 15px; line-height: 1.32; overflow-wrap: anywhere; }
.pmeta { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; margin-top: 3px; }
.tagchip {
  display: inline-block; margin-left: 7px; padding: 1px 6px;
  border: 1px solid var(--line-strong); color: var(--muted);
  font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; vertical-align: 2px;
}
.leader { flex: 1; border-bottom: 1px dotted var(--line-strong); align-self: flex-end; margin: 0 2px 5px; }
.pright { text-align: right; flex: none; }
.price { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.actzone { margin-top: 8px; min-height: 30px; display: flex; justify-content: flex-end; }
.line-sum { margin-top: 5px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.addbtn {
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding: 7px 12px; cursor: pointer; transition: all .12s;
}
.addbtn:active, .addbtn:hover { background: var(--ink); color: var(--paper); }

.stepper {
  display: inline-flex; align-items: stretch; border: 1px solid var(--ink);
}
.step-btn {
  width: 30px; height: 30px; border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.step-btn .ic { width: 13px; height: 13px; stroke-width: 2.2; }
.step-btn:active { background: var(--ink); color: var(--paper); }
.qty {
  min-width: 26px; text-align: center; font-weight: 700; font-size: 13.5px;
  display: flex; align-items: center; justify-content: center;
  border-left: 1px solid var(--ink); border-right: 1px solid var(--ink);
  font-variant-numeric: tabular-nums;
}

/* скиелетон */
.skel-box {
  background: linear-gradient(90deg, var(--paper2) 25%, var(--line) 50%, var(--paper2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-row { height: 62px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; padding: 6px 0; }
.skel-name { height: 13px; width: 56%; } .skel-meta { height: 9px; width: 34%; margin-top: 6px; } .skel-price { height: 13px; width: 64px; margin-left: auto; }

/* ============ корзина ============ */
.page-head h1 { font-size: 24px; margin: 0 0 2px; font-weight: 500; }

.checkout {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 64px;
  width: min(100%, 520px); z-index: 35;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--paper) 36%);
}
.checkout textarea {
  width: 100%; resize: none; border: 1px solid var(--line-strong); background: var(--paper2);
  color: var(--ink); padding: 9px 12px; font-size: 13.5px; outline: none; font-family: inherit; margin-bottom: 10px;
}
.checkout textarea:focus { border-color: var(--ink); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.total-row span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.total-row b { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  cursor: pointer; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  transition: filter .12s, transform .1s;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
html:not(.dark) .btn.primary:hover, html:not(.dark) .btn.primary:not(:disabled):active { filter: brightness(1.12); }
.btn.big { width: 100%; padding: 15px; font-size: 13.5px; }
.btn.loading, .btn[disabled] { opacity: .55; }
.hint { color: var(--muted); font-size: 11.5px; text-align: center; margin: 9px 0 0; line-height: 1.5; }

/* ============ пустые состояния ============ */
.empty { text-align: center; padding: 66px 20px; }
.empty p { font-family: var(--serif); font-size: 18px; margin: 14px 0 4px; }
.empty span { color: var(--muted); font-size: 12.5px; }
.empty-ic {
  width: 52px; height: 52px; fill: none; stroke: var(--line-strong); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.footnote {
  color: var(--muted); font-size: 11.5px; text-align: center;
  padding: 18px 34px 24px; line-height: 1.65;
  border-top: 1px solid var(--line);
}

/* ============ заказы ============ */
.orow {
  padding: 14px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
  position: relative; animation: fadein .25s ease both;
}
.orow:active { background: var(--paper2); }
.orow-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.orow-id { font-family: var(--serif); font-size: 19px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.chip .dotc { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.st-new      .dotc { background: var(--steel); }
.st-invoice  .dotc { background: var(--amber); }
.st-paid     .dotc { background: var(--green); }
.st-shipped  .dotc { background: var(--violet); }
.st-done     .dotc { background: var(--gray); }
.st-cancelled.dotc, .st-cancelled .dotc { background: var(--red); }
.chip strong { color: var(--ink); font-weight: 600; }
.orow-sums { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.orow-sums span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.orow-sums b { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.orow-preview { color: var(--muted); font-size: 12.5px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-unread { color: var(--ink); font-weight: 600; }
.unread-dot {
  position: absolute; left: -8px; top: 21px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--red);
}

/* ============ экран заказа и чат ============ */
#view-order { display: flex; flex-direction: column; height: 100dvh; max-width: 520px; margin: 0 auto; }
#view-order.hidden { display: none !important; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line-strong); background: var(--paper);
  position: sticky; top: 0; z-index: 30;
}
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--line-strong); background: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink);
}
.icon-btn:active { background: var(--ink); color: var(--paper); }
.icon-btn .ic { width: 17px; height: 17px; }
.chat-title b { font-family: var(--serif); font-size: 19px; font-weight: 600; display: block; }
.chat-title > span { font-size: 11.5px; }

.chat-scroll { flex: 1; overflow-y: auto; padding: 16px 16px 6px; }
.order-card { border: 1px solid var(--line-strong); padding: 4px 14px 12px; margin-bottom: 18px; }
.order-card h4 {
  margin: 0; padding: 10px 0 9px; font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .14em; font-weight: 650;
  border-bottom: 1px solid var(--line);
}
.oc-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dotted var(--line-strong); }
.oc-line:last-of-type, .oc-total { border-bottom: none; }
.oc-meta { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }
.oc-qty { color: var(--muted); font-variant-numeric: tabular-nums; }
.oc-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.oc-total {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px solid var(--ink); margin-top: 2px; padding-top: 10px;
}
.oc-total .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-family: var(--sans); }
.oc-total b { font-size: 21px; font-weight: 600; }
.oc-note { color: var(--muted); font-size: 12.5px; padding: 8px 0 0; }
.trackline {
  margin-top: 10px; padding: 9px 12px; border: 1px dashed var(--violet); color: var(--ink);
  font-size: 13px;
}
.trackline b { letter-spacing: .04em; }

.msg { max-width: 88%; margin-bottom: 12px; font-size: 14.5px; line-height: 1.5; }
.msg.user {
  margin-left: auto; background: var(--green-soft);
  border-left: 3px solid var(--green); padding: 9px 13px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.admin {
  background: var(--paper2); border: 1px solid var(--line); border-left: 3px solid var(--ink);
  padding: 9px 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg .time {
  display: block; margin-top: 5px; font-size: 10px; color: var(--muted);
  letter-spacing: .05em;
}
.msg.system {
  max-width: 96%; margin-left: auto; margin-right: auto; text-align: left;
  background: transparent; border: 1px dashed var(--line-strong); color: var(--muted);
  font-size: 12.5px; padding: 9px 13px;
}
.msg.system .time { text-align: right; }

.invoice-card {
  max-width: 96%;
  border: 1px solid var(--ink); padding: 0; margin-right: auto; margin-bottom: 14px;
}
.inv-head {
  padding: 9px 14px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--paper); background: var(--ink);
  display: flex; justify-content: space-between;
}
.inv-head b { letter-spacing: .02em; }
.inv-body { padding: 12px 14px 6px; }
.inv-amount { font-size: 27px; padding-bottom: 10px; border-bottom: 1px dotted var(--line-strong); }
.inv-requisites { padding: 11px 0 4px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; }
.copy-chip {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  border: none; background: none; padding: 7px 0; border-bottom: 1px dotted var(--line-strong);
  color: var(--green); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.copy-chip:last-of-type { border-bottom: none; }
.copy-chip .ic { width: 13px; height: 13px; flex: none; }
.copy-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-card .time { padding: 0 14px 10px; }

.chat-closed {
  text-align: center; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .12em;
  padding: 16px 12px 20px; position: relative;
}
.chat-closed::before, .chat-closed::after {
  content: ''; display: block; height: 1px; background: var(--line); margin: 10px 0;
}

.composer {
  display: flex; gap: 10px; padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px);
  border-top: 1px solid var(--line-strong); background: var(--paper);
}
.composer input {
  flex: 1; min-width: 0; border: 1px solid var(--line-strong); background: var(--paper2);
  color: var(--ink); padding: 11px 14px; font-size: 14.5px; outline: none;
}
.composer input:focus { border-color: var(--ink); }
.send-btn {
  width: 44px; border: 1px solid var(--green); background: var(--green); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.send-btn .ic { width: 17px; height: 17px; }
.send-btn:active { filter: brightness(1.15); }

/* ============ админка внутри миниаппа ============ */
.fl { display: block; font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 11px; }
.fl input, .fl textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid var(--line-strong); background: var(--paper2); color: var(--ink);
  font-size: 14px; outline: none; font-family: inherit; letter-spacing: normal;
  text-transform: none; font-weight: 400; resize: vertical;
}
.fl input:focus, .fl textarea:focus { border-color: var(--ink); }

.segbar {
  display: flex; gap: 18px; margin-top: 13px; overflow-x: auto; scrollbar-width: none;
}
.segbar::-webkit-scrollbar { display: none; }
.segbar button {
  background: none; border: none; cursor: pointer; padding: 4px 1px 8px;
  font-size: 12.5px; font-weight: 650; letter-spacing: .05em; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.segbar button.on { color: var(--ink); border-color: var(--green); }

.adm-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acard { border: 1px solid var(--line-strong); padding: 10px 12px; }
.acard .k { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.acard .v { font-family: var(--serif); font-size: 19px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.acard.g .v { color: var(--green); } .acard.a .v { color: var(--amber); }

.adm-bars { display: flex; align-items: flex-end; gap: 3px; height: 64px; margin: 14px 0 6px; }
.adm-bars i { flex: 1; background: var(--green); min-height: 2px; }
.adm-bars-cap { display: flex; gap: 3px; }
.adm-bars-cap span { flex: 1; font-size: 8.5px; color: var(--muted); text-align: center; }

.adm-list-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px dotted var(--line-strong); font-size: 13.5px; }

.adm-row { padding: 11px 0; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }

.actgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.abtn {
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  padding: 11px 6px; font-size: 11px; font-weight: 750; letter-spacing: .06em;
  text-transform: uppercase; cursor: pointer; text-align: center;
}
.abtn:active, .abtn:hover { background: var(--ink); color: var(--paper); }
.abtn.green { border-color: var(--green); color: var(--green); }
.abtn.green:active, .abtn.green:hover { background: var(--green); color: #fff; }
.abtn.red { border-color: var(--red); color: var(--red); }
.abtn.red:active, .abtn.red:hover { background: var(--red); color: #fff; }
.abtn[disabled] { opacity: .4; }

.sheet-bg { position: fixed; inset: 0; background: rgba(20,16,8,.45); z-index: 80; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 520px); max-height: 86dvh; overflow-y: auto; z-index: 81;
  background: var(--paper); border: 1px solid var(--ink); border-bottom: none;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
  animation: sheetup .22s ease both;
}
@keyframes sheetup { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet h3 { font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0 0 14px; }
.sheet label { display: block; font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 11px; }
.sheet input, .sheet textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid var(--line-strong); background: var(--paper2); color: var(--ink);
  font-size: 14px; outline: none; font-family: inherit; letter-spacing: normal; text-transform: none; resize: vertical;
}
.sheet input:focus, .sheet textarea:focus { border-color: var(--ink); }
.sheet .sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

.whotag {
  align-self: center; flex: none; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--paper); background: var(--ink); padding: 5px 7px;
}

/* ============ нижнее меню ============ */
.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 520px); display: flex; z-index: 45;
  background: var(--paper);
  border-top: 1px solid var(--line-strong);
  padding: 8px 4px calc(env(safe-area-inset-bottom) + 7px);
}
.bottomnav button {
  flex: 1; background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 3px 0 1px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .15s;
}
.bottomnav button span { font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.bottomnav button.on { color: var(--ink); }
.bubble, .navdot {
  position: absolute; top: -3px; right: calc(50% - 16px);
  min-width: 15px; height: 15px; border-radius: 8px; padding: 0 4px;
  background: var(--ink); color: var(--paper);
  font-size: 9px; font-weight: 800; font-style: normal; line-height: 15px; text-align: center;
}
.navdot { background: var(--red); }

/* ============ тост ============ */
.toast {
  position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 64px); z-index: 70;
  margin: 0 auto; max-width: min(92vw, 480px);
  background: var(--ink); color: var(--paper);
  font-size: 13px; text-align: center; padding: 10px 16px;
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: none; }
