/* Просто и удобно: обяснения (всички екрани) + телефон (до 760px). Зарежда се след style.css. */
.help { margin: -12px 0 20px; font-size: 15px; line-height: 1.5; color: var(--muted); max-width: 720px; }
.stat .l .hint { display: block; margin-top: 3px; font-size: 12px; line-height: 1.35; color: var(--muted); letter-spacing: 0; }
.navgroup { margin: 16px 12px 6px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.boardhint, #phonebar, .filterbtn { display: none; }
/* Без продавачи и обаждащи (SALES_TEAM = false): скрито, не изтрито. */
body.noteam #owner, body.noteam .teamonly { display: none !important; }

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  body { font-size: 16px; }
  body.has-bar { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .brandbar { padding: 8px 10px; }
  .brandbar img { height: 40px; }
  .brandbar .client { font-size: 10px; letter-spacing: .14em; text-align: center; }

  /* Менюто: скрито, отваря се с „☰ Меню“ */
  .shell { display: block; min-height: 0; }
  .shell > .side {
    display: none; position: fixed !important; z-index: 40; left: 0; right: 0; top: 0 !important; bottom: calc(68px + env(safe-area-inset-bottom));
    width: 100% !important; height: auto !important; flex-direction: column !important; flex-wrap: nowrap; overflow-y: auto !important; overflow-x: hidden !important;
    padding: 14px 14px 20px !important; background: var(--panel) !important; border: 0 !important; gap: 4px;
  }
  body.menu-open .shell > .side { display: flex !important; }
  body.menu-open { overflow: hidden; }
  .side a.nav { display: block; flex: 0 0 auto; white-space: normal !important; font-size: 17px !important; padding: 14px 14px !important; margin: 0 !important; border-radius: 12px !important; background: rgba(212,169,55,.05); color: var(--text); }
  .side a.nav.on { background: rgba(212,169,55,.18) !important; box-shadow: inset 4px 0 0 var(--orange) !important; }
  .side .sep, .side .who { display: block !important; flex: 0 0 auto; }
  .side-bottom { display: flex !important; flex-direction: column; gap: 4px; margin-top: 8px !important; }

  #phonebar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; background: #06130c; border-top: 1px solid rgba(212,169,55,.2); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  #phonebar a, #phonebar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; background: none; border: 0; border-radius: 12px; color: var(--muted); cursor: pointer; padding: 2px; }
  #phonebar b { font-size: 21px; font-weight: 400; line-height: 1.1; }
  #phonebar span { font-size: 12px; }
  #phonebar .on, body.menu-open #phonebar #menubtn { background: rgba(212,169,55,.16); color: var(--text); }

  .main { padding: 16px 12px 40px !important; max-width: 100vw; }
  h1 { font-size: 22px !important; margin-bottom: 10px !important; }
  .help { margin: 0 0 16px; }
  h2 { margin-top: 24px; font-size: 12px; }
  .card { padding: 16px 14px; }
  .grid, .grid.g2, .grid.g3 { grid-template-columns: 1fr !important; gap: 10px; }
  .grid.g4 { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .stat { padding: 12px 12px; }
  .stat .v { font-size: 25px; overflow-wrap: anywhere; }

  /* Големи бутони и полета (16px, за да не увеличава сам iPhone) */
  .btn { min-height: 46px; font-size: 15px; }
  .btn.small { min-height: 42px; padding: 8px 12px; font-size: 14px; }
  input, select, textarea { font-size: 16px !important; min-height: 46px; max-width: 100% !important; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: 22px !important; height: 22px; }
  .row { max-width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch !important; }
  .toolbar > * { width: 100% !important; max-width: 100% !important; flex: 0 0 auto !important; }
  /* Старите дълги обяснения не трябват на телефон: горе вече има едно просто изречение. */
  .main > .help + p.muted, .main > .help + .card > p.muted:first-child { display: none; }
  /* Филтрите са скрити зад един бутон, за да се виждат веднага хората */
  .filterbtn { display: block !important; width: 100%; margin: 0 0 8px; }
  .toolbar.folded > *:not(input[type="search"]):not(.filterbtn) { display: none !important; }
  .formgrid { grid-template-columns: 1fr !important; }
  .pagehead { flex-direction: column; align-items: stretch; }
  .pagehead .row { flex-direction: column; align-items: stretch; }
  .pagehead .row > * { width: 100%; }
  .seg, .segsel, .tabs { display: flex; flex-wrap: wrap !important; gap: 4px; max-width: 100%; overflow: visible !important; }
  .seg button, .segsel button, .tabs button { flex: 1 1 30%; min-height: 42px; white-space: normal; font-size: 14px; }
  .codebox { flex-wrap: wrap; }
  code, pre, .payload { white-space: pre-wrap; overflow-wrap: anywhere; }

  /* Таблиците стават карти */
  .tablewrap { overflow: visible !important; border: 0 !important; background: transparent !important; max-height: none !important; }
  table.cards, table.cards tbody, table.cards tr, table.cards td, table.cards th { display: block; width: auto !important; min-width: 0 !important; }
  table.cards tr.headrow { display: none; }
  table.cards tr { background: var(--panel); border: 1px solid var(--line); 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: 7px 0 !important; border: 0 !important; text-align: right !important; white-space: normal !important; position: static !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; text-align: left; font-size: 12px; color: var(--muted); text-transform: none; font-weight: 400; }
  table.cards td:first-child { font-weight: 600; }
  table.cards td .row { justify-content: flex-end; flex: 1 1 100%; }
  table.cards .bar { min-width: 90px; }

  /* Колоните с контактите: плъзгане с пръст */
  .boardhint { display: block; margin: 10px 0; font-size: 14px; color: var(--muted); }
  .board { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; margin: 0 -12px !important; padding: 0 12px 14px !important; }
  .board > * { flex: 0 0 84vw !important; width: 84vw !important; min-width: 0 !important; scroll-snap-align: center; }

  /* Прозорците: на цял екран, над долното меню */
  .modalbg { z-index: 60; padding: 0 !important; }
  .modal { width: 100% !important; min-height: 100%; border-radius: 0 !important; padding: 18px 14px 40px !important; }
  .modal .row > .btn { flex: 1 1 45%; }

  .portals { grid-template-columns: 1fr !important; width: 100%; }
  .portal { min-height: 84px; }
  .center { padding: 16px 12px; }
  .chat-fab { bottom: calc(84px + env(safe-area-inset-bottom)) !important; right: 10px !important; width: 46px !important; height: 46px !important; font-size: 21px !important; }
  .smsm { grid-template-columns: 1fr !important; display: block !important; }
  .smsm .card { margin-bottom: 12px; }
  .bar { max-width: 100%; }
  .row > div[style*="width:230px"] { width: 100% !important; }
}
