/* jione CRM — фирменный стиль */
:root {
  --orange: #F58220;
  --orange-hover: #E37414;
  --orange-soft: #FFF3E8;
  --bg: #FFFFFF;
  --bg-alt: #FAFAFA;
  --border: #E5E7EB;
  --text: #111827;
  --text-muted: #6B7280;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-alt);
  min-height: 100vh;
}
a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-hover); }

.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: 240px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo {
  font-weight: 700;
  font-size: 18px;
  padding: 0 24px 20px;
  border-bottom: 1px solid var(--border);
  letter-spacing: .5px;
}
.sidebar .logo .accent { color: var(--orange); }
.sidebar nav { padding: 12px 0; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--text);
  font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--bg-alt); }
.sidebar nav a.active {
  background: var(--orange-soft);
  border-left-color: var(--orange);
  color: var(--orange);
}
.sidebar nav a .icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar .footer-note {
  position: absolute;
  bottom: 16px;
  left: 24px;
  right: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.pwa-actions {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pwa-btn {
  display: block;
  text-align: left;
  padding: 9px 12px;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.pwa-btn:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.pwa-btn:disabled { opacity: .7; cursor: default; }
.pwa-btn-mini { padding: 6px 10px; font-size: 12px; color: var(--text-muted); }
#pwa-status { font-size: 11px; color: var(--text-muted); padding: 0 4px; min-height: 14px; line-height: 1.3; }

/* ── MAIN ── */
.main { flex: 1; padding: 24px 32px; max-width: 100%; overflow-x: auto; }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.page-header .meta { color: var(--text-muted); font-size: 13px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--orange-hover); color: white; }
.btn.secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg-alt); }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* ── CARDS ── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ── STAT TILES ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
}
.stat-tile:hover { border-color: var(--orange); }
.stat-tile.active { border-color: var(--orange); background: var(--orange-soft); }
.stat-tile .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-tile .value { font-size: 22px; font-weight: 600; }

/* ── TABLES ── */
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
table.data th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 14px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: var(--bg-alt); }

/* Телефон не должен переноситься посередине */
table.data .phone-line { white-space: nowrap; }
table.data td.col-contact { min-width: 170px; white-space: nowrap; }
table.data td.col-customer { min-width: 200px; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: #f3f4f6;
  color: #374151;
  white-space: nowrap;
}
.badge.source { background: #EEF2FF; color: #4338CA; }
.supplier-badge { color: var(--text); }
.supplier-badge:hover { background: var(--orange-soft); color: var(--orange); }

/* ── FORMS ── */
form.form { display: grid; gap: 14px; max-width: 600px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=number], input[type=email], input[type=tel], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.1);
}
textarea { resize: vertical; min-height: 80px; }

/* ── SEARCH BAR ── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.search-bar .search-input {
  flex: 1;
  padding: 11px 16px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.search-bar .search-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,130,32,.15); }

/* ── HINTS ── */
.hint {
  background: var(--orange-soft);
  border-left: 3px solid var(--orange);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 18px;
  color: #7C3F0F;
}
.hint strong { color: var(--text); }

/* ── EMPTY STATE ── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty .big { font-size: 48px; margin-bottom: 12px; opacity: .3; }

/* ── DETAIL VIEW ── */
.detail-grid { display: grid; grid-template-columns: 200px 1fr; gap: 8px 20px; margin: 16px 0; }
.detail-grid .k { color: var(--text-muted); font-size: 13px; }
.detail-grid .v { font-size: 14px; }

/* ── BRAND/SUPPLIER GROUPS ── */
.result-group { margin-bottom: 20px; }
.result-group h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.result-group h3 .tag {
  background: var(--orange-soft);
  color: var(--orange);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.discount-pill {
  display: inline-block;
  background: #ECFDF5;
  color: #047857;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
}

/* ── TABS UNDER SEARCH ── */
.mode-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.mode-tabs a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}
.mode-tabs a.active { background: var(--orange); color: white; border-color: var(--orange); }

/* ── ТОПБАР (только на мобильных) ── */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  align-items: center;
  gap: 12px;
}
.topbar .hamburger {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.topbar-logo { font-weight: 700; font-size: 16px; }
.topbar-logo .accent { color: var(--orange); }
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
}

/* ── КНОПКИ МЕССЕНДЖЕРОВ ── */
.contact-btns {
  display: inline-flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.cb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 13px;
  text-decoration: none;
  color: white !important;
  transition: transform .1s, opacity .1s;
}
.cb:hover { transform: scale(1.1); opacity: .9; color: white !important; }
.cb-call  { background: #6B7280; }
.cb-wa    { background: #25D366; }
.cb-tg    { background: #229ED9; }
.cb-viber { background: #7360F2; }
.cb-max   { background: #FFC517; color: #000 !important; }
.cb-max:hover { color: #000 !important; }

/* ── BEST PRICE (товары) ── */
tr.row-best { background: #ECFDF5 !important; }
tr.row-best:hover { background: #D1FAE5 !important; }
.best-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #047857;
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ── SUPPLIER CARD META (под именем поставщика) ── */
.supplier-card-meta {
  background: var(--bg-alt);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}

/* ─────────────────────────────────────────────────────
   MOBILE (≤ 880px)
   ───────────────────────────────────────────────────── */
@media (max-width: 880px) {
  body { font-size: 15px; }

  .topbar { display: flex; }

  .layout { display: block; }

  /* sidebar становится выезжающим */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 60;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .backdrop { display: block; }

  .sidebar nav a {
    padding: 14px 24px;
    font-size: 15px;
  }

  .main { padding: 16px 14px; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header h1 { font-size: 19px; }

  /* Поиск/фильтры в столбик */
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar select, .search-bar .search-input { max-width: none !important; width: 100%; }

  /* Формы — одна колонка */
  .form-row { grid-template-columns: 1fr; }
  form.form { max-width: none; }

  /* Кнопки — крупнее под палец */
  .btn { padding: 11px 18px; font-size: 15px; min-height: 44px; }
  .btn.small { padding: 7px 12px; font-size: 13px; min-height: 32px; }

  /* Stats: горизонтальный скролл */
  .stats {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
  }
  .stat-tile { min-width: 130px; scroll-snap-align: start; flex-shrink: 0; }
  .stat-tile .value { font-size: 19px; }

  /* Таблицы → горизонтальный скролл, но карточный режим для основных */
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 10px 8px; }

  /* Заказы — карточный режим */
  .orders-list-mobile { display: block; }
  .order-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  /* Detail-grid — одной колонкой */
  .detail-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .detail-grid .k { color: var(--text-muted); font-size: 12px; margin-top: 8px; }

  /* Кнопки мессенджеров крупнее на мобильном */
  .cb { width: 32px; height: 32px; font-size: 15px; }
  .contact-btns { gap: 6px; margin-top: 6px; }

  /* Скрыть некоторые столбцы в /products на мобильном */
  table.data .col-mobile-hide { display: none; }

  /* ── ТАБЛИЦЫ → КАРТОЧКИ (без горизонтального скролла) ── */
  .table-scroll, .result-group {
    overflow-x: visible;
  }
  table.data,
  table.data thead,
  table.data tbody,
  table.data tr,
  table.data td,
  table.data th {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  table.data { border: none; background: transparent; }
  table.data thead { display: none; }
  table.data tr {
    display: block;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--bg);
    box-shadow: var(--shadow);
    cursor: default;
  }
  table.data tr[onclick] { cursor: pointer; }
  table.data tr:hover { background: var(--bg); }
  table.data td {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px;
    align-items: start;
    padding: 5px 0;
    border: none;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
  }
  table.data tr td:last-child { border-bottom: none; }
  table.data td:before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
    font-weight: 500;
    padding-top: 2px;
  }
  table.data td:not([data-label]):before { display: none; }
  table.data td:not([data-label]) { grid-template-columns: 1fr; }
  /* Минимум — не сжимать ширину контента */
  .result-group table.data { min-width: 0; }
}

/* ── Превью товара в заказе ── */
.order-product-cell {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.order-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  flex-shrink: 0;
}
.order-product-text { min-width: 0; flex: 1; }
@media (max-width: 880px) {
  .order-thumb { width: 48px; height: 48px; }
}

/* ── Кликабельный товар (из заказа в /products) ── */
.product-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--orange);
  padding-bottom: 1px;
}
.product-link:hover {
  color: var(--orange);
  border-bottom-style: solid;
}

/* ── ТОВАРЫ ── */
.product-block { padding-bottom: 8px; }
.product-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.product-head h3 { margin: 0; }
.product-head-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}
.product-thumb-link { flex-shrink: 0; line-height: 0; }
.product-thumb {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  transition: transform .2s;
}
.product-thumb:hover { transform: scale(1.05); border-color: var(--orange); }
.product-rrp { font-size: 14px; color: var(--text-muted); }
@media (max-width: 880px) {
  .product-thumb { width: 60px; height: 60px; }
}
.product-rrp strong { color: var(--text); font-size: 16px; }

.our-prices { background: var(--bg-alt); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.our-prices-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.price-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.price-tile {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.price-tile.our {
  background: linear-gradient(135deg, #FFF3E8 0%, #FFFFFF 100%);
  border-color: var(--orange);
}
.price-tile .pl {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.price-tile .pv { font-size: 17px; font-weight: 600; }
.price-tile.our .pv { color: var(--orange); }
.price-tile .pd { font-size: 11px; color: #047857; margin-top: 2px; }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.dot.avito { background: #00B8FF; }
.dot.site  { background: #F58220; }
.dot.ozon  { background: #005BFF; }
.dot.wb    { background: #CB11AB; }
.dot.ym    { background: #FFCC00; }

@media (max-width: 880px) {
  .price-tiles { grid-template-columns: repeat(2, 1fr); }
  .price-tile .pv { font-size: 15px; }
}

/* ── РЕДАКТОР КП: предпросмотр в одну колонку перед share-кнопками ── */
.qpp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.quote-preview-iframe {
  display: block;
  width: 100%;
  height: 700px;
  border: none;
  background: #f5f5f5;
}
@media (max-width: 880px) {
  .quote-preview-iframe { height: 65vh; min-height: 480px; }
}

/* ── ОТПРАВКА КП ── */
.quote-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.qa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: white !important;
  min-height: 48px;
  transition: opacity .15s, transform .1s;
}
.qa-btn:hover { opacity: .92; transform: translateY(-1px); color: white !important; }
.qa-pdf { background: #4B5563; }
.qa-wa  { background: #25D366; }
.qa-tg  { background: #229ED9; }
.qa-max { background: #FFC517; color: #111 !important; }
.qa-max:hover { color: #111 !important; }

table.quote-items input { width: 100%; padding: 6px 8px; font-size: 13px; }
table.quote-items td { vertical-align: middle; }

/* Мобильный режим редактора КП: каждая позиция = карточка с полями в колонку */
@media (max-width: 880px) {
  table.quote-items tr {
    padding: 14px 14px 10px;
    background: var(--bg);
  }
  table.quote-items td {
    /* лейбл сверху, инпут снизу на полную ширину */
    display: block;
    grid-template-columns: 1fr;
    border-bottom: none;
    padding: 4px 0 6px;
  }
  table.quote-items td:before {
    display: block;
    margin-bottom: 3px;
    padding-top: 0;
  }
  table.quote-items td.qi-num {
    position: absolute;
    top: 12px;
    right: 50px;
    background: var(--orange-soft);
    color: var(--orange);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    padding: 0;
  }
  table.quote-items td.qi-num:before { display: none; }
  table.quote-items tr { position: relative; padding-top: 44px; }
  /* кнопка удалить — в правый верхний угол карточки */
  table.quote-items td:last-child {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0;
  }
  table.quote-items td:last-child:before { display: none; }
  /* Сумма позиции справа — крупно */
  table.quote-items td.qi-sum {
    border-top: 1px dashed var(--border);
    padding-top: 8px;
    margin-top: 4px;
    text-align: right;
    font-size: 15px;
  }
  table.quote-items tfoot td { padding: 14px; }
  table.quote-items tfoot td[colspan] { display: none; }  /* "ИТОГО:" слева не нужен в карточном виде */
  table.quote-items tfoot tr { padding: 12px 14px; }
}

@media (max-width: 880px) {
  .quote-actions { grid-template-columns: 1fr; }
}

/* ── ВХОД ── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #FFF3E8 0%, #FFFFFF 50%, #FAFAFA 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .08);
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 28px;
  letter-spacing: .5px;
}
.login-error {
  background: #FEE2E2;
  color: #B91C1C;
  border-left: 3px solid #B91C1C;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; }
.login-form label > span { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.login-form input { padding: 11px 14px; font-size: 15px; border: 1px solid var(--border); border-radius: 8px; }
.login-form input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,130,32,.12); outline: none; }
.login-form button {
  margin-top: 6px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.login-form button:hover { background: var(--orange-hover); }

.banner {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}
.banner-ok  { background: #ECFDF5; border-left: 3px solid #047857; color: #047857; }
.banner-err { background: #FEE2E2; border-left: 3px solid #B91C1C; color: #B91C1C; }

/* ── ВЛОЖЕНИЯ ── */
.attachments-list { display: grid; gap: 8px; }
.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.att-preview-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.att-preview-link:hover { color: var(--orange); }
.att-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.att-meta { flex: 1; min-width: 0; }
.att-name {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-size { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* DOCX preview — стилизация под документ */
.docx-preview {
  max-width: 800px;
  margin: 0 auto;
  font-family: "Times New Roman", Times, serif;
  line-height: 1.5;
  color: #222;
  background: white;
}
.docx-preview h1, .docx-preview h2, .docx-preview h3 { font-family: -apple-system, sans-serif; }
.docx-preview p { margin: 0.6em 0; }
.docx-preview table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.docx-preview table td, .docx-preview table th {
  border: 1px solid #ccc; padding: 6px 10px;
}

/* XLSX/XLS preview */
.xlsx-preview {
  border-collapse: collapse;
  font-size: 13px;
  background: white;
  margin-bottom: 20px;
  table-layout: auto;
}
.xlsx-preview td {
  border: 1px solid #d0d0d0;
  padding: 5px 8px;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 400px;
}

/* iPhone safe area */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .main   { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
}
