/* SalesFox Work — в одном семействе с платформой: тёплый лисий оранжевый как единственный акцент */
:root {
  --fox-50: #fff6ed; --fox-100: #ffead4; --fox-500: #e8590c; --fox-600: #c94a07; --fox-700: #a33c08;
  --ink: #1f1a17; --paper: #faf8f6; --line: #e7e2dd; --muted: #6f6660;
  --red: #b42318; --red-bg: #fde2e1; --red-ink: #9f1d15; --yel-bg: #fef3c7; --yel-ink: #854d0e;
  --grn-bg: #dcfce7; --grn-ink: #166534; --blue-bg: #e0ecff; --blue-ink: #1d4ed8;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--fox-700); } a:hover { color: #7a2d06; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); } .sm { font-size: 12px; } .b { font-weight: 600; } .red { color: var(--red); } .r { text-align: right; }
.stage-banner { position: sticky; top: 0; z-index: 50; background: #fcd34d; color: #451a03; text-align: center; font-size: 12px; font-weight: 600; padding: 4px; }

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 232px; max-width: 260px; background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.side a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side a:hover { background: var(--paper); }
.side a[aria-current="page"] { background: var(--fox-50); color: var(--fox-700); font-weight: 600; }
.side .brand { justify-content: flex-start; font-weight: 600; font-size: 16px; padding: 4px 10px 18px; }
.side .brand:hover { background: none; }
.fox { color: var(--fox-500); }
.cnt { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.cnt .red { color: var(--red); }
.divider { height: 1px; background: var(--line); margin: 10px 6px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; }
.ava { width: 34px; height: 34px; border-radius: 50%; background: var(--fox-100); color: var(--fox-700); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.acts { display: flex; gap: 8px; align-items: center; }
.content { padding: 22px 28px 40px; max-width: 1200px; display: flex; flex-direction: column; gap: 16px; }
.bare .content { max-width: 420px; margin: 8vh auto; }

.btn, .btn-ghost, .btn-danger, .btn-green { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border-radius: 8px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn { background: var(--fox-600); color: #fff; border: 0; } .btn:hover { background: var(--fox-700); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; } .btn-ghost:hover { background: var(--paper); color: var(--ink); }
.btn-danger { background: #fff; color: var(--red-ink); border: 1px solid #f4c7c3; font-weight: 500; }
.btn-green { background: #f0fbf3; color: var(--grn-ink); border: 1px solid #b7dfc4; }
.inl { display: inline; margin: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-end; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi .v { font-size: 28px; font-weight: 700; } .kpi .l { font-size: 12px; color: var(--muted); }
.tbl { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.tbl table { width: 100%; border-collapse: collapse; min-width: 760px; }
.tbl th { background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; padding: 10px 14px; }
.tbl td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tr.closed td { color: #9b938d; }
.tbl a.t { font-weight: 600; text-decoration: none; }
.code { color: var(--muted); white-space: nowrap; font-weight: 600; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-red { background: var(--red-bg); color: var(--red-ink); } .pill-yellow { background: var(--yel-bg); color: var(--yel-ink); }
.pill-green { background: var(--grn-bg); color: var(--grn-ink); } .pill-blue { background: var(--blue-bg); color: var(--blue-ink); }
.pill-gray { background: #f3eee9; color: #4a4440; } .pill-fox { background: var(--fox-50); color: var(--fox-700); }

form.filters, .form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
form.filters { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); min-height: 32px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 18px; height: 18px; accent-color: var(--fox-600); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fox-100); border-color: var(--fox-500); }
textarea { resize: vertical; min-height: 70px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fgrid .wide { grid-column: 1 / -1; }
.hint { font-size: 11px; color: var(--muted); }
.ok { margin: 0; padding: 10px 14px; border-radius: 10px; background: #f0fbf3; color: var(--grn-ink); }
.err { margin: 0; padding: 10px 14px; border-radius: 10px; background: #fdf1f0; color: var(--red-ink); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; width: fit-content; }
.tabs a { padding: 7px 16px; border-radius: 7px; text-decoration: none; color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--fox-50); color: var(--fox-700); font-weight: 600; }
dl.kv { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
dl.kv dt { font-size: 12px; color: var(--muted); } dl.kv dd { margin: 2px 0 0; }
.feed .item { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.feed .meta { font-size: 12px; color: var(--muted); }
.feed p { margin: 4px 0 0; white-space: pre-line; }
.file { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px; margin-top: 6px; }
.kira { background: var(--fox-50); border: 1px solid var(--fox-100); border-radius: 12px; padding: 12px 16px; }
details > summary { cursor: pointer; font-weight: 600; }
.bar { height: 8px; background: #f3eee9; border-radius: 4px; margin-top: 4px; } .bar > div { height: 8px; background: var(--fox-500); border-radius: 4px; }

/* ---------- Фильтры (на компьютере раскрыты, на телефоне свёрнуты) ---------- */
form.filters .fsearch { flex: 1 1 260px; }
details.fmore { flex: 1 1 100%; }
details.fmore > summary { list-style: none; }
details.fmore > summary::-webkit-details-marker { display: none; }
.fbody { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.fbtns { display: flex; gap: 8px; }
@media (min-width: 721px) { details.fmore > summary { display: none; } details.fmore { flex-basis: auto; } }

/* ---------- Телефонные элементы: на компьютере скрыты ---------- */
.mtop, .mbar, .tcards, .tact { display: none; }
.mlist a { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); font-size: 16px; }
.mlist a:first-child { border-top: 0; }
.mlist { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.mlist .divider { height: 6px; margin: 0; background: var(--paper); }
.me-card { display: flex; align-items: center; gap: 12px; }
html.tg .tg-hide { display: none !important; }

/* ---------- Телефон ---------- */
@media (max-width: 720px) {
  body { font-size: 15px; -webkit-tap-highlight-color: transparent; }
  .side, .top { display: none; }
  .main { flex-basis: 100%; }
  .mtop { display: flex; position: sticky; top: 0; z-index: 30; justify-content: space-between; align-items: center; height: 52px; padding: 0 14px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
  .stage-banner + .shell .mtop { top: 24px; }
  .mtop .brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 16px; }
  .mtop .ava { text-decoration: none; width: 36px; height: 36px; }
  html.tg .mtop { display: none; }
  .content { padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); gap: 12px; }
  h1 { font-size: 20px; } h2 { font-size: 16px; }
  .head { gap: 10px; align-items: flex-start; }
  .head > .btn-ghost { display: none; } /* выгрузки CSV — с компьютера */

  /* Нижняя панель */
  .mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 4px 4px env(safe-area-inset-bottom); }
  .mbar a { flex: 1 1 0; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 4px; color: var(--muted); text-decoration: none; font-size: 11px; min-height: 52px; justify-content: center; }
  .mbar a[aria-current="page"] { color: var(--fox-700); font-weight: 600; }
  .mbar a.plus { flex: 0 0 64px; }
  .mbar a.plus svg { width: 46px; height: 46px; padding: 11px; border-radius: 50%; background: var(--fox-600); color: #fff; box-shadow: 0 4px 12px rgba(201,74,7,.35); }
  .mbar .badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--muted); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; text-align: center; }
  .mbar .badge.hot { background: var(--red); }

  /* Показатели — компактно в одну строку */
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .grid3 .card { padding: 10px 10px; }
  .kpi .v { font-size: 22px; line-height: 1.2; } .kpi .l { font-size: 11px; line-height: 1.25; }

  /* Тикеты: карточки вместо таблицы */
  .tbl.tickets { display: none; }
  .tcards { display: flex; flex-direction: column; gap: 8px; }
  .tc { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
  .tc:active { background: var(--fox-50); }
  .tc.closed { opacity: .7; }
  .tc-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .tc-top .code { font-size: 13px; }
  .tc-risk { margin-left: auto; }
  .tc-title { font-weight: 600; font-size: 16px; line-height: 1.3; margin-top: 6px; color: var(--ink); }
  .tc-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
  .tc-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 8px; font-size: 13px; }

  /* Остальные таблицы: каждая строка — карточка «подпись: значение» */
  .tbl:not(.keep) { background: none; border: 0; overflow: visible; }
  .tbl:not(.keep) table, .tbl:not(.keep) tbody { display: block; min-width: 0 !important; }
  .tbl:not(.keep) thead { display: none; }
  .tbl:not(.keep) tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; margin-bottom: 8px; }
  .tbl:not(.keep) td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid #f1ece7; text-align: right; }
  .tbl:not(.keep) td:first-child { border-top: 0; display: block; text-align: left; font-size: 15px; }
  .tbl:not(.keep) td:first-child::before { display: none; }
  .tbl:not(.keep) td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; max-width: 45%; }
  .tbl:not(.keep) td:not([data-label])::before { display: none; }
  .tbl:not(.keep) td:empty { display: none; }
  .tbl.keep table { min-width: 0 !important; font-size: 13px; }
  .tbl.keep th, .tbl.keep td { padding: 8px 8px; }

  /* Фильтры */
  form.filters { padding: 10px; gap: 8px; }
  form.filters .fsearch { flex-basis: 100%; }
  form.filters .fsearch { font-size: 0; gap: 0; } /* подпись «Поиск» не нужна — есть подсказка в поле */
  details.fmore > summary { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; font-weight: 500; background: #fff; }
  details.fmore[open] > summary { background: var(--fox-50); border-color: var(--fox-100); color: var(--fox-700); margin-bottom: 10px; }
  .fbody { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .fbody label { min-width: 0; } .fbody select { width: 100%; }
  .fbtns { grid-column: 1 / -1; } .fbtns > * { flex: 1; }
  form.filters:not(:has(.fmore)) { display: grid; grid-template-columns: 1fr 1fr; }
  form.filters:not(:has(.fmore)) select { width: 100%; }
  form.filters:not(:has(.fmore)) > button, form.filters:not(:has(.fmore)) > label:only-of-type { grid-column: 1 / -1; }
  .tabs { width: 100%; } .tabs a { flex: 1; text-align: center; padding: 8px 6px; }

  /* Поля ввода: 16px — чтобы iPhone не увеличивал страницу при вводе */
  input, select, textarea { font-size: 16px; min-height: 44px; }
  .fgrid { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 14px; }
  .fgrid > * { min-width: 0; } input[type=file] { max-width: 100%; font-size: 13px; }
  .fgrid .row { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: #fff; padding: 8px 0 0; }
  .fgrid .row > * { flex: 1; }
  .btn, .btn-ghost, .btn-danger, .btn-green { min-height: 44px; }

  /* Карточка тикета */
  .row > section, .row > .card { flex-basis: 100% !important; min-width: 0; }
  .content > * { min-width: 0; max-width: 100%; }
  .tbtns { display: none !important; }
  dl.kv { gap: 10px 14px; }
  dl.kv dd { font-size: 14px; }
  .feed { scroll-margin-top: 60px; }
  .tact { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 35; padding: 8px 12px; background: rgba(250,248,246,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
  .tact > .btn { flex: 1; }
  .tact .sheet > summary { list-style: none; cursor: pointer; }
  .tact .sheet > summary::-webkit-details-marker { display: none; }
  .tact .sheet[open] > summary { background: var(--fox-50); color: var(--fox-700); }
  .sheet-body { position: fixed; left: 8px; right: 8px; bottom: calc(124px + env(safe-area-inset-bottom)); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(31,26,23,.18); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
  .sheet-body form, .sheet-body button { width: 100%; }
  body:has(.tact) .content { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .filepick { flex: 1 1 100%; min-width: 0; flex-wrap: wrap; }
  .filepick input[type=file] { max-width: 100%; font-size: 13px; }
  .feed form .row { flex-wrap: wrap; } .feed form .btn { flex: 1 1 100%; }

  /* Вход */
  .bare .content { margin: 6vh auto; padding: 16px; }
}
@media (max-width: 360px) { .kpi .v { font-size: 19px; } .mbar a { font-size: 10px; } .fbody { grid-template-columns: 1fr; } }

/* Телефон, где нет нижней панели Telegram-кнопок: в мини-приложении шапку даёт сам Telegram */
html.tg body { background: var(--paper); }
