/* SoldbyK CRM на телефон (до 800px) и номерата за набиране с едно докосване (28.11.2026).
   Зарежда се след style.css. Само добавка: на десктоп нищо не се мести, номерата само стават линкове
   със същия цвят като текста. Цветовете са от променливите на style.css (темата не се сменя). */
#phonebar, .telbig, .filterbtn { display: none; }
a.tel { color: inherit; }

@media (max-width: 800px) {
  html { overflow-x: hidden; }
  body { overflow-x: clip; }

  /* ---------- долно меню: 3 главни бутона на текущия портал + „☰ Меню“ ---------- */
  #phonebar {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: rgba(13,13,16,.96); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line2);
  }
  #phonebar a, #phonebar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 58px; min-width: 0; padding: 4px 2px; border: 0; border-radius: 12px; background: none;
    color: var(--muted); font: inherit; font-size: 11.5px; line-height: 1.15; text-align: center; cursor: pointer;
  }
  #phonebar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  #phonebar svg { width: 24px; height: 24px; flex: 0 0 24px; stroke: currentColor; }
  #phonebar .on, body.menu-open #phonebar #menubtn { color: var(--orange2); background: rgba(255,138,31,.10); }
  body.has-bar .main { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
  body.has-bar .toast, body.has-mobnav .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  body.has-bar .supportbar, body.has-mobnav .supportbar { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

  /* Страничното меню: скрито; „☰ Меню“ го отваря на цял екран (с портали, разделите и изхода). */
  body.has-bar .shell > .side { display: none; }
  body.has-bar.menu-open { overflow: hidden; }
  body.has-bar.menu-open .shell > .side {
    display: flex; flex-direction: column; flex-wrap: nowrap; gap: 2px;
    position: fixed; z-index: 44; top: 0; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    width: 100%; height: auto; padding: 16px 14px 20px; overflow-x: hidden; overflow-y: auto;
    background: var(--bg2); border: 0;
  }
  body.menu-open .side .navlabel { display: block; padding: 16px 12px 6px; }
  body.menu-open .side .portalswitch { display: grid; margin: 0 0 6px; }
  body.menu-open .side .portalswitch a { min-height: 46px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
  body.menu-open .side a.nav { flex: 0 0 auto; min-height: 50px; padding: 12px 14px; margin: 0; font-size: 17px; white-space: normal; }
  body.menu-open .side a.nav svg { width: 22px; height: 22px; flex-basis: 22px; }
  body.menu-open .side .side-bottom { display: block; margin-top: 14px; padding-top: 0; }
  body.menu-open .side .usercard { display: flex; }
  body.menu-open .side .usercard a { min-width: 46px; min-height: 46px; place-items: center; }

  /* ---------- шапка и съдържание ---------- */
  .brandbar { padding: 0 10px; }
  .brandbar .client { max-width: calc(100vw - 210px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .auditlink { min-height: 40px; }
  button.avatar { width: 40px; height: 40px; }
  .umenu-list a { padding: 13px 12px; font-size: 16px; }
  .main { max-width: 100vw; }
  .brandbar > a { display: flex; align-items: center; min-height: 44px; }
  .banner a, .main p a:not(.btn):not(.telpill), .modal p a:not(.btn):not(.telpill), .svc-card .sub a[href^="mailto:"] { padding: 12px 0; }
  a.btn { display: inline-flex; align-items: center; justify-content: center; }
  .grid.g4 { grid-template-columns: 1fr 1fr; }
  .stat .v { overflow-wrap: anywhere; }

  /* Големи бутони и полета (16px, за да не увеличава сам iPhone) */
  .btn, .btn.small { min-height: 44px; }
  .btn.small { padding: 8px 12px; font-size: 14px; }
  input:not([type="checkbox"]):not([type="radio"]), select { min-height: 46px; font-size: 16px; max-width: 100%; }
  textarea { font-size: 16px; max-width: 100%; }
  input[type="checkbox"], input[type="radio"] { width: 22px !important; height: 22px; }
  .seg { display: flex; flex-wrap: wrap; overflow: visible; max-width: 100%; }
  .seg button { flex: 1 1 auto; min-height: 44px; white-space: normal; }
  .tabs button { min-height: 44px; flex: 1 1 auto; }
  .row.toolbar > *, .toolbar > select, .toolbar > input { flex: 1 1 100%; width: 100%; max-width: 100%; }
  .row.toolbar > .btn, .row.toolbar > button { flex: 1 1 auto; }
  .pagehead { flex-direction: column; align-items: stretch; }
  .pagehead > .row { flex-direction: column; align-items: stretch; }
  .pagehead > .row > * { width: 100%; }
  .modal .row > .btn, .modal .row > button { flex: 1 1 40%; }
  .modal .row > span[style*="flex:1"] { display: none; }
  code, pre, .payload { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
  .codebox code { flex: 1 1 100%; }
  .center { margin: 28px auto; }
  .center .muted a, .center p > a, .portals + p a { display: inline-block; padding: 10px 0; }
  .presetopt { padding: 12px; }
  .finpair { grid-template-columns: 1fr; }
  .finbox svg { max-width: 100%; height: auto; }
  .fleg { grid-template-columns: 14px 1fr auto 38px; }
  .mbtags { max-height: 260px; }
  .mbtag { min-height: 40px; }

  /* Филтрите на лийдовете: видима е само търсачката, останалото е зад „Филтри“ */
  .filterbtn { display: block; width: 100%; }
  .toolbar.folded > *:not(input[type="search"]):not(.filterbtn) { display: none !important; }

  /* ---------- таблиците стават карти ---------- */
  .tablewrap { overflow: visible !important; padding: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; max-height: none !important; }
  .mgb .tablewrap { padding: 8px 8px 0 !important; }
  table.cards, table.cards tbody, table.cards tr, table.cards td, table.cards th { display: block; width: auto !important; min-width: 0 !important; max-width: none !important; }
  table.cards { table-layout: auto !important; }
  table.cards tr.headrow { display: none; }
  table.cards tr { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 6px 14px; margin-bottom: 10px; }
  table.cards td, table.cards th {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px;
    padding: 8px 0 !important; border: 0 !important; text-align: right; white-space: normal !important;
    overflow: visible !important; text-overflow: clip !important; overflow-wrap: anywhere; background: transparent !important;
    text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text);
  }
  table.cards td:empty, table.cards th:empty { display: none; }
  table.cards [data-label]:not([data-label=""])::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); }
  table.cards td.cardtitle { justify-content: flex-start; text-align: left; font-size: 16.5px; font-weight: 650; color: #fff; padding-top: 10px !important; }
  table.cards td.cardtitle::before { display: none; }
  table.cards td[colspan] { justify-content: flex-start; text-align: left; }
  table.cards td .row { justify-content: flex-end; flex: 1 1 100%; }
  table.cards td > select { flex: 1 1 60%; max-width: none !important; width: auto !important; }
  table.cards .bar { min-width: 90px; }
  /* Широки таблици с числа (напр. „Всичко по месеци“): по две полета на ред, за да е по-къса картата */
  table.cards.many tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
  table.cards.many tr.headrow { display: none; }
  table.cards.many td, table.cards.many th { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; text-align: left; }
  table.cards.many [data-label]:not([data-label=""])::before { max-width: none; }
  table.cards.many tr > :first-child { grid-column: 1 / -1; flex-direction: row; font-size: 16px; font-weight: 650; }
  table.cards.many tr > :first-child::before { display: none; }
  tr.click:hover td { background: transparent !important; }
  tr.click:active { background: rgba(255,255,255,.05); }

  /* Колоните (ако има табло с колони): плъзгане с пръст по една */
  .board { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px 14px; }
  .board > .col { flex: 0 0 84vw; width: 84vw; max-height: none; scroll-snap-align: center; }

  /* Прозорците: на цял екран, над долното меню */
  .modalbg { z-index: 60; }
  .modal { max-width: 100vw; padding: 16px 14px 40px !important; overflow-wrap: anywhere; }
  .modal p { overflow-wrap: anywhere; }
  .modal .badge, .modal .tag { white-space: normal; }

  /* ---------- номерата: голямо хапче „📞 0888 123 456“, докосването само набира ---------- */
  a.telpill {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 8px 14px; border-radius: 999px; white-space: nowrap; text-align: center;
    background: rgba(62,214,140,.12); border: 1px solid rgba(62,214,140,.45); color: var(--text);
    font-weight: 650; font-size: 16px; font-variant-numeric: tabular-nums; text-decoration: none;
  }
  a.telpill.telico::before { content: "📞"; font-size: 15px; }
  a.telpill:active { background: rgba(62,214,140,.28); }
  /* Номер на мястото на името (контакт без име): заглавието остава заглавие, бутонът за обаждане е отделно */
  h1 a.telpill, h2 a.telpill, h3 a.telpill, td.cardtitle a.telpill, .svc-card .nm a.telpill { min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; font: inherit; color: inherit; }
  h1 a.telpill::before, h2 a.telpill::before, h3 a.telpill::before, td.cardtitle a.telpill::before, .svc-card .nm a.telpill::before { display: none; }
  .svc-card .sub a.telpill { margin-top: 2px; }
  /* Списъкът за звънене на сетъра: бутонът за обаждане е на цяла ширина */
  body[data-page="/setter/calls"] table.cards td.telcell a.telpill { flex: 1 1 100%; min-height: 52px; font-size: 18px; }
  body[data-page="/setter/calls"] table.cards td .row > .btn { flex: 1 1 45%; }
  /* Детайл на лийд/клиент: „📞 Обади се“ най-горе, на цяла ширина */
  a.telbig {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    width: 100%; min-height: 58px; margin: 6px 0 14px; padding: 8px 14px; border-radius: 14px;
    background: linear-gradient(135deg, #5fe3a3 0%, #2fbf78 100%); color: #06140d; text-decoration: none;
    font-size: 19px; font-weight: 750; box-shadow: 0 10px 24px -10px rgba(62,214,140,.7);
  }
  a.telbig small { font-size: 13.5px; font-weight: 600; opacity: .8; font-variant-numeric: tabular-nums; }
  a.telbig:active { filter: brightness(.95); }
}

/* 28.11: до големия „📞 Обади се“ малкото „Звънни“ в детайла е излишно (прави същото). */
@media (max-width: 800px) {
  .modal:has(.telbig) a.btn.small[href^="tel:"] { display: none !important; }
}
