/* Личный справочник — оформление по макету Mini App.
   Правило: названия и тексты не обрезаются многоточием — длинный текст переносится,
   высота блока растёт. */

@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --line: #D6DAE1;
  --line-strong: #A9B2BF;
  --text: #16181D;
  --muted: #5A6472;
  --accent: #1A56DB;
  --accent-dark: #143FA0;
  --accent-bg: #E8EEFB;
  --green: #0A6B38;
  --green-line: #0E8345;
  --green-bg: #E6F4EC;
  --warn: #8F4107;
  --warn-bg: #FDF3E3;
  --danger: #B42318;
  --danger-bg: #FCEAE8;
  --track: #E4E7EC;
  --subtle: #FAFBFC;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font-family: inherit; color: var(--text); }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- каркас: шапка, прокручиваемая середина, низ ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  height: var(--tg-viewport-height, 100dvh);
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 482px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.head {
  flex: none;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.head:empty { display: none; }
.head.with-back { padding-top: 8px; gap: 6px; }
.head h1 { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.head-row { display: flex; align-items: center; gap: 8px; }
.head-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.back {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.body > * { flex: none; }

.foot {
  flex: none;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 10px 16px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav {
  flex: none;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.nav a {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;            /* пять разделов: подписи целиком помещаются на экране 390 px */
  color: var(--muted);
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
@media (max-width: 374px) { .nav a { font-size: 10px; } }
@media (max-width: 339px) { .nav { padding-left: 0; padding-right: 0; } .nav a { font-size: 9px; } }
.nav svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- кнопки ---------- */

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
}
.icon-btn:hover { color: var(--text); }
.icon-btn.arrow { font-size: 18px; }

.btn {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { color: var(--text); }
.btn.wide { display: flex; min-height: 48px; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }

.btn-primary {
  min-height: 52px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  width: 100%;
}
.btn-primary:hover { color: #fff; background: var(--accent-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.link-btn {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: none;
  border: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  width: 100%;
}

/* переключатели: «На карту / За рубеж / На счёт», вкладки, чипы */
.seg { display: flex; gap: 6px; }
.seg.wrap { flex-wrap: wrap; }
.seg.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
.seg button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.seg.wrap button { flex: none; max-width: 100%; padding: 6px 14px; text-align: left; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- карточки и строки ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
a.card:hover { color: var(--text); }
.card.tight { padding: 12px; gap: 6px; }
.card.best { border-color: var(--green-line); }
.card.accent { border-color: var(--accent); }
.card.flat { padding: 0; gap: 0; }
.card h2, .card h3 { font-size: 15px; font-weight: 700; }
.card h2.big { font-size: 17px; }
.card h2.bigger { font-size: 18px; }
.card.flat > h2 { padding: 12px 14px 8px; }

.section-title { font-size: 15px; font-weight: 700; margin-top: 4px; }

.row {
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}
a.row { min-height: 44px; }
a.row:hover { color: var(--text); }
.card.flat > .row + .row,
.card.flat > h2 + .row,
.card.flat > .row + .link-btn,
.card.flat > .group + .row,
.card.flat > .row + .group,
.card.flat > h2 + .group,
.card.flat > .bar-row,
.card.flat > .note + .link-btn,
.card.flat > h2 + .link-btn { border-top: 1px solid var(--line); }
.row.slim { padding: 10px 14px; }
.row.code { padding: 9px 14px; font-size: 14px; align-items: baseline; }
.row.hl { background: var(--accent-bg); }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.col { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.small14 { font-size: 14px; }
.gap-top { margin-top: 8px; }
.phone { font-size: 14px; font-weight: 500; }
.route-top { display: flex; gap: 10px; align-items: baseline; }
.provider-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card-head { display: flex; gap: 12px; align-items: center; }
.card-head .btn, .provider-top .btn { flex: none; }
.card.summary { padding: 12px 14px; gap: 6px; }
.card.accent.summary { gap: 8px; }
.card.report-link { flex-direction: row; align-items: center; padding: 12px 14px; }
.report-link .more { flex: none; font-size: 14px; font-weight: 600; color: var(--accent); }
.card.example { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 10px; }
.seg button.off { opacity: .6; }
.row .end { flex: none; text-align: right; max-width: 55%; }
.row .num { flex: none; font-weight: 600; white-space: nowrap; }
.codecol { flex: none; width: 34px; color: var(--muted); font-weight: 500; }

.group {
  padding: 6px 14px;
  background: var(--subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.strong { font-weight: 600; }
.bold { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.green { color: var(--green); }
.red { color: var(--danger); }
.warn-text { color: var(--warn); font-weight: 600; font-size: 13px; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.off { opacity: .55; }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  flex: none;
}
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.blue { background: var(--accent-bg); color: var(--accent); }
.pill.red { background: var(--danger-bg); color: var(--danger); }
.pill.grey { background: #EEF0F3; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.kv { display: flex; justify-content: space-between; gap: 10px; }
/* подпись переносится только по словам (короткое «Чек» не рвётся на буквы), значение — где угодно */
.kv > :first-child { color: var(--muted); min-width: min-content; overflow-wrap: break-word; }
.kv > :last-child { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv.plain > :first-child { color: var(--text); }
.kv.total { border-top: 1px solid var(--line); padding-top: 6px; align-items: baseline; }
.kv.total > :first-child { color: var(--text); font-weight: 600; }
.kvs { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

.note-blue { background: var(--accent-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.card.flat > .note { padding: 0 14px 12px; }

.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
.bar.thin { height: 6px; border-radius: 3px; }
.bar-row { padding: 8px 14px; display: flex; flex-direction: column; gap: 4px; }
.bar-row:last-child { padding-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 5px; }

.option { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: block; color: var(--text); text-decoration: none; }
a.option { min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
a.option:hover { color: var(--text); }
.option.best { border-color: var(--green-line); }
.option .top { display: flex; justify-content: space-between; gap: 8px; }
.option .top > :first-child { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.option .top > :last-child { font-weight: 700; text-align: right; flex: none; max-width: 50%; overflow-wrap: anywhere; }
.option.best .top > :last-child { color: var(--green); }

.tiles { display: flex; gap: 8px; }
.tile { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile.inner { border-radius: 8px; padding: 8px 10px; }
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.tile.inner .value { font-size: 16px; font-weight: 600; }

.badge {
  flex: none;
  width: 40px;
  height: 28px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.badge.large { width: 56px; height: 38px; border-radius: 8px; font-size: 13px; }

.route-cost { flex: none; font-size: 18px; font-weight: 700; white-space: nowrap; }
.total-big { font-size: 20px; font-weight: 700; white-space: nowrap; }

/* ---------- формы ---------- */

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row2 { display: flex; gap: 10px; align-items: flex-end; }
.row2 > .field { flex: 1; }

.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
}
textarea.input { padding: 10px 12px; resize: none; line-height: 1.35; min-height: 72px; }
.input.strong { font-weight: 600; }
.input.big {
  min-height: 52px;
  border: 2px solid var(--accent);
  font-size: 26px;
  font-weight: 700;
}
.input::placeholder { color: #8A93A0; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.check { min-height: 44px; display: flex; gap: 10px; align-items: center; font-size: 15px; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); margin: 0; }
.check span { min-width: 0; overflow-wrap: anywhere; }
.field > label.check { font-size: 15px; color: var(--text); }
.group-field { gap: 0; }
.group-field > .label { margin-bottom: 2px; }
.check.boxed { min-height: 48px; background: var(--accent-bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

.pair { display: flex; gap: 6px; align-items: center; }
.pair .input { flex: 1; min-width: 0; }
.pair .icon-btn { font-size: 20px; }

.subhead { font-size: 15px; font-weight: 700; margin-top: 6px; }

.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.empty { text-align: center; gap: 8px; padding: 20px 14px; }
.empty .title { font-size: 16px; font-weight: 700; }

/* ---------- подтверждение удаления ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 24, 29, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.dialog {
  width: 100%;
  max-width: 448px;
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dialog .text { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.dialog .btn { width: 100%; min-height: 48px; }

.noscript { padding: 24px 16px; text-align: center; }

/* ---------- товары, чеки, классификатор, точки ---------- */

.head-row .btn { flex: none; }
.grey { color: #8A93A0; }
.cmp { display: flex; flex-direction: column; gap: 1px; }
.item-card { gap: 6px; }
.choice { border-top: 1px dashed var(--line); padding-top: 8px; gap: 6px; }
.warn-card { border-color: var(--warn); background: var(--warn-bg); }
.text-link {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-align: left;
}
.point-row { align-items: center; }
.point-link { min-height: 44px; display: flex; flex-direction: column; justify-content: center; color: var(--text); text-decoration: none; }
.point-link:hover { color: var(--text); }
.card.flat > .row + .point-row, .card.flat > h2 + .point-row, .card.flat > .point-row + .link-btn { border-top: 1px solid var(--line); }
.dialog.picker { max-height: 88vh; max-height: 88dvh; }
.picker-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 60px; }
.pick {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  text-align: left;
  font-size: 15px;
  overflow-wrap: anywhere;
}

/* ---------- план счетов, проводки, ведомость ---------- */

.codecol.wide { width: auto; min-width: 40px; max-width: 108px; overflow-wrap: anywhere; }
.chart-row .pills { margin-top: 3px; }
.pick-btn { height: auto; padding: 10px 12px; text-align: left; line-height: 1.3; overflow-wrap: anywhere; }
.pick-btn.placeholder { color: #8A93A0; }
.pick-group { padding: 6px 2px 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.posting-row { align-items: flex-start; }
.posting-main { display: flex; flex-direction: column; gap: 2px; min-height: 44px; color: var(--text); text-decoration: none; }
.posting-main:hover { color: var(--text); }
.posting-main .pills { margin-top: 2px; }
.card.flat > .posting-row + .posting-row, .card.flat > h2 + .posting-row, .card.flat > .note + .posting-row,
.card.flat > .posting-row + .link-btn, .card.flat > .posting-row + .note { border-top: 1px solid var(--line); }
.card.flat > .posting-row + .note, .card.flat > h2 + .note + .posting-row { padding-top: 10px; }
.card.flat > .posting-row + .note { padding: 10px 14px 12px; }
.doc-link { display: inline-flex; align-items: center; justify-content: flex-end; min-height: 32px; font-size: 13px; font-weight: 600; text-decoration: none; }
.posting-line { align-items: flex-start; }
.posting-line > :first-child { color: var(--text); }
.tb { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 14px; row-gap: 2px; width: 100%; font-size: 13px; margin-top: 4px; }
.tb .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 78px; }
.tb .hd { font-size: 12px; color: var(--muted); }
.trial-row { align-items: flex-start; }
.card.flat > .trial-row + .trial-row, .card.flat > h2 + .trial-row { border-top: 1px solid var(--line); }
a.tile { display: block; color: var(--text); text-decoration: none; }
a.tile:hover { color: var(--text); }
.balance-tile { display: flex; flex-direction: column; gap: 2px; }
.field.none { flex: none; }
.period .row2 { align-items: flex-end; }
.period .seg.wrap button { min-height: 40px; padding: 4px 12px; }
.dialog .btn-primary { min-height: 48px; }
.card.flat > .row.slim + .row.slim { border-top: 1px solid var(--line); }

/* ---------- транспорт: карта, подразделы, маршруты ---------- */

.seg.tabs a {
  flex: 1; min-width: 0; min-height: 40px; padding: 6px 4px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none;
  display: flex; align-items: center; justify-content: center; text-align: center; overflow-wrap: anywhere;
}
.seg.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.body.map-body { padding: 0; gap: 0; overflow: hidden; position: relative; }
.body.map-body > .map { flex: 1; min-height: 220px; }
.map { width: 100%; background: #E8EAED; z-index: 0; }
.pick-map { height: 52vh; height: 52dvh; border-radius: 8px; }
.map-info {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 5; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 4px 16px rgba(22, 24, 29, .18);
  max-height: 60%; overflow-y: auto;
}
.map-info[hidden], .map-hint[hidden] { display: none; }
.map-hint {
  position: absolute; left: 8px; right: 8px; top: 8px; z-index: 5; background: var(--card); border-radius: 8px; padding: 6px 10px;
  font-size: 13px; color: var(--muted); text-align: center; box-shadow: 0 2px 8px rgba(22, 24, 29, .15);
}
.map-credit { display: block; background: rgba(255, 255, 255, .9); padding: 2px 6px; font-size: 11px; color: #16181D; text-decoration: none; border-radius: 4px; }
.map-credit.ya-logo { font-size: 14px; font-weight: 700; padding: 4px 8px; letter-spacing: -.2px; }
.map-credit.ya-logo::first-letter { color: #FC3F1D; }
.pin { border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(22, 24, 29, .5); background: #5A6472; }
.pin-home { background: #0E8345; }
.pin-work { background: #1A56DB; }
.pin-other { background: #5A6472; }
.pin-shop { background: #B45309; border-radius: 6px; }
.pin-pick { background: #B42318; }
.route-option { display: flex; flex-direction: column; gap: 6px; }
.route-option .seg.wrap .btn { min-height: 40px; }
.leg { gap: 8px; }
.leg-head { display: flex; align-items: center; gap: 6px; }
.leg-head > :first-child { flex: 1; }
.icon-btn.small { width: 40px; height: 40px; font-size: 18px; }
.pair .grow { align-self: center; }
.trip-summary { flex: none; padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line); max-height: 48%; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.quick-trip { flex-direction: column; gap: 2px; padding: 10px 12px; }
.quick-trip .xs { font-weight: 500; opacity: .9; }
