/* ── AGENT MOBILE LAYER ──
   Дизайн-слой мобильного кабинета агента. Подключается после mobile.css
   (media max-width:768px) и действует ТОЛЬКО при body.agent-mobile —
   класс ставит agent-mobile.js для роли agent. Без класса ни одно правило
   не применяется, остальные роли и desktop не затронуты. */

body.agent-mobile {
  background: #eef1f4;
}

/* ── Шапка ── */
body.agent-mobile .topbar {
  background: linear-gradient(160deg, #4A7C59 0%, #3a6347 100%);
  border-bottom: 0;
  min-height: 52px;
  padding: 10px 14px;
}

body.agent-mobile .topbar-logo {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.2px;
}

body.agent-mobile .header-menu-toggle {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 10px;
}

/* ── Hero: приветствие + баланс (рисует agent-mobile.js) ── */
#am-hero {
  display: none;
}

body.agent-mobile #am-hero {
  display: block;
  background: linear-gradient(160deg, #3a6347 0%, #2d5a3d 100%);
  padding: 4px 16px 16px;
  color: #fff;
}

body.agent-mobile .am-hero-hello {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.3px;
  padding-top: 6px;
}

body.agent-mobile .am-hero-stats {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

body.agent-mobile .am-stat {
  flex: 1;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  padding: 10px 12px;
  color: #fff;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body.agent-mobile .am-stat:active {
  opacity: .75;
}

body.agent-mobile .am-stat b {
  display: block;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
}

body.agent-mobile .am-stat span {
  display: block;
  font-size: 11px;
  opacity: .8;
  margin-top: 2px;
}

/* ── Нижняя навигация: иконка + подпись ── */
body.agent-mobile .tabs {
  height: auto;
  min-height: 60px;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  gap: 0;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(16px);
  border-top: 1px solid #e5e9ee;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, .10);
}

body.agent-mobile .nav-tab {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border: none;
  border-radius: 12px;
  color: #8a97a5;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

body.agent-mobile .nav-tab .tab-icon {
  display: block;
  font-size: 21px;
  line-height: 1;
}

body.agent-mobile .nav-tab .tab-label,
body.agent-mobile .nav-tab {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
}

body.agent-mobile .nav-tab .tab-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.agent-mobile .nav-tab.active {
  background: #e8f5e9;
  border: none;
  color: #3a6347;
  font-weight: 700;
}

body.agent-mobile .nav-tab .tab-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  margin-left: 0 !important;
  border: 1.5px solid #fff;
}

/* ── Контент ── */
body.agent-mobile .app-body {
  padding: 12px 12px 20px;
}

body.agent-mobile .card {
  border: none;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .07);
}

/* ── Тулбар и поиск как в макете ── */
body.agent-mobile .toolbar {
  background: transparent;
  padding: 0 0 10px;
  margin-bottom: 0;
}

body.agent-mobile .si {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 13px;
  min-height: 46px;
  font-size: 16px;
  padding-left: 14px;
}

body.agent-mobile .si:focus {
  border-color: var(--c-primary);
}

body.agent-mobile .btn {
  border-radius: 12px;
  font-weight: 700;
}

body.agent-mobile .btn-p {
  box-shadow: 0 3px 10px rgba(74, 124, 89, .30);
}

/* ── Списки-карточки (строки таблиц движка) ── */
body.agent-mobile table:not(.dashboard-table):not(.platform-tree) tbody tr:not(.empty-row) {
  border: none;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .07);
  margin-bottom: 10px;
}

body.agent-mobile table:not(.dashboard-table):not(.platform-tree) td {
  border-bottom: 1px solid #f1f5f9;
  padding: 10px 14px !important;
}

body.agent-mobile table:not(.dashboard-table):not(.platform-tree) td::before {
  font-size: 10px;
  letter-spacing: .4px;
  color: #8a97a5;
}

body.agent-mobile tr.clickable:active td {
  background: #f8fafc;
}

body.agent-mobile .badge {
  border-radius: 99px;
  padding: 3px 10px;
}

body.agent-mobile .empty-row td {
  padding: 40px 16px !important;
  color: #8a97a5;
  font-size: 14px;
}

/* ── Пейджер ── */
body.agent-mobile .pager {
  gap: 10px;
}

body.agent-mobile .pager-btn {
  border-radius: 12px;
  min-width: 52px;
  border-color: #e2e8f0;
}

/* ── Группированный список направлений ── */
body.agent-mobile .grouped-list {
  padding: 8px;
  gap: 10px;
}

body.agent-mobile .group-card {
  border: none;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .07);
}

body.agent-mobile .group-header {
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  box-shadow: inset 4px 0 0 var(--c-primary);
  padding: 12px 14px;
  gap: 6px;
}

body.agent-mobile .group-items {
  margin: 8px 8px 10px 14px;
  padding-left: 10px;
  border-left: 2px solid #e5e9ee;
}

body.agent-mobile .group-item {
  border: 1px solid #f1f5f9;
  border-radius: 12px;
  gap: 5px;
}

body.agent-mobile .group-item:active {
  background: #f8fafc;
}

body.agent-mobile .group-filter-bar {
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px 12px;
  margin: 0 0 10px;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .06);
}

body.agent-mobile .group-filter-bar input,
body.agent-mobile .group-filter-bar select,
body.agent-mobile .group-sort select {
  min-height: 40px;
  border-radius: 10px;
  border-color: #e2e8f0;
}

/* ── Модалки как bottom sheet ── */
body.agent-mobile .modal {
  align-items: flex-end;
  justify-content: stretch;
  padding: 0;
}

body.agent-mobile .modal-box,
body.agent-mobile .modal-box.modal-pick-list,
body.agent-mobile .linked-preview-modal {
  width: 100vw !important;
  max-width: 100vw !important;
  height: auto !important;
  min-height: 40dvh;
  max-height: 94dvh !important;
  margin: 0;
  border-radius: 22px 22px 0 0;
  padding: 24px 16px 16px;
  animation: am-sheet-up .28s cubic-bezier(.32, .72, 0, 1);
}

@keyframes am-sheet-up {
  from { transform: translateY(40px); opacity: .4; }
  to { transform: translateY(0); opacity: 1; }
}

body.agent-mobile .modal-box::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #d1d5db;
}

body.agent-mobile .modal-title {
  font-size: 17px;
}

body.agent-mobile .modal-close-x {
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
}

body.agent-mobile .mf input,
body.agent-mobile .mf select,
body.agent-mobile .mf textarea {
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  min-height: 46px;
}

body.agent-mobile .mf input:focus,
body.agent-mobile .mf select:focus,
body.agent-mobile .mf textarea:focus {
  border-color: var(--c-primary);
}

body.agent-mobile .modal-actions .btn {
  min-height: 48px;
  border-radius: 13px;
}

/* Алерты/подтверждения — компактный sheet */
body.agent-mobile #alert-modal .modal-box,
body.agent-mobile #confirm-modal .modal-box,
body.agent-mobile #prompt-modal .modal-box {
  min-height: 0;
}

/* ── Подсказки ── */
body.agent-mobile .hint-box,
body.agent-mobile .pf-hint {
  border-radius: 14px;
  border-color: #fde68a;
}

/* ── Профиль и документы ── */
body.agent-mobile .pf-card {
  padding: 16px;
}

body.agent-mobile .docs-container {
  border-radius: 14px;
  border-color: #e5e9ee;
}

/* ── Кнопка «Сообщить об ошибке» над нижней навигацией ── */
body.agent-mobile .report-issue-btn {
  bottom: calc(84px + env(safe-area-inset-bottom));
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(231, 76, 60, .35);
}

/* ── Выпадающее меню шапки ── */
body.agent-mobile .header-dropdown {
  border: none;
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(15, 23, 42, .22);
}
