* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); }

/* Боковое меню: на телефоне — шапка с прокручиваемыми вкладками, на компьютере — колонка слева */
.side { position: sticky; top: 0; z-index: 5; background: var(--side); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 12px 16px 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: .08em; }
.brand .logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; font-size: .95rem; letter-spacing: 0; }
.side nav { display: flex; gap: 2px; overflow-x: auto; padding: 0 10px 8px; scrollbar-width: none; }
.side nav::-webkit-scrollbar { display: none; }
.side nav form { margin: 0; }
.nav-link, .side button.nav-link { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font: inherit; font-weight: 500; white-space: nowrap; background: none; border: 0; cursor: pointer; width: 100%; justify-content: flex-start; }
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link:hover, .side button.nav-link:hover { background: var(--chip); color: var(--text); }
.nav-link.on { background: var(--chip-hover); color: var(--text); }
.nav-sep { display: none; }
/* телефон: логотип и вкладки в одной строке, название приложения скрыто */
@media (max-width: 899px) {
  body.has-side .side { display: flex; align-items: center; }
  body.has-side .brand { padding: 8px 4px 8px 12px; }
  body.has-side .brand-name { display: none; }
  body.has-side .side nav { flex: 1; min-width: 0; padding: 0 8px; }
  body.has-side .nav-link, body.has-side .side button.nav-link { min-height: 36px; padding: 0 8px; }
}
@media (min-width: 900px) {
  body.has-side { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
  body.has-side .side { height: 100vh; border-bottom: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
  body.has-side .brand { padding: 18px 18px 14px; }
  body.has-side .side nav { flex-direction: column; flex: 1; overflow: visible; padding: 4px 10px 14px; }
  body.has-side .nav-sep { display: block; flex: 1; }
}

button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--brand-ink); }
main { max-width: 880px; margin: 0 auto; padding: 16px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
a.card { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.card:hover { border-color: var(--border-strong); }
h1 { font-size: 1.35rem; font-weight: 600; margin: .2em 0 .7em; letter-spacing: -.01em; } h2 { font-size: 1.1rem; font-weight: 600; }
label { display: block; margin: 12px 0 6px; font-weight: 500; font-size: .93rem; }
/* 16px в полях — иначе iPhone увеличивает страницу при вводе */
input, select, textarea { width: 100%; padding: 10px 12px; font: 16px/1.4 var(--font); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; background: var(--card); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
.btn, button { padding: 10px 16px; font: inherit; font-weight: 500; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn:hover, button:hover { background: var(--brand-hover); }
.btn.secondary, button.secondary { background: var(--chip); color: var(--text); }
.btn.secondary:hover, button.secondary:hover { background: var(--chip-hover); }
.btn.danger, button.danger { background: var(--danger-soft); color: var(--danger-ink); }
.btn.small { padding: 0 12px; min-height: 36px; font-size: .93rem; }
.muted { color: var(--muted); font-size: .88rem; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: .78rem; font-weight: 500; background: var(--chip); color: var(--muted); }
.badge.red { background: var(--danger-soft); color: var(--danger-ink); } .badge.orange { background: var(--warn-soft); color: var(--warn-ink); } .badge.green { background: var(--ok-soft); color: var(--ok-ink); }
/* Выбор файлов: системная кнопка спрятана, вместо неё .btn со скрепкой (собирается скриптом в base.html) */
.filepick { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0; font-weight: 400; }
.filepick input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; }
.filepick .btn svg { width: 18px; height: 18px; }
.filepick:focus-within .btn { outline: 2px solid var(--brand); outline-offset: 1px; }
.filepick .names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft-2); color: var(--brand-ink); font-weight: 600; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--ok-soft); color: var(--text); }
.msg.error { background: var(--danger-soft); } .msg.warn { background: var(--warn-soft); }
.messages { max-width: 880px; margin: 0 auto; padding: 12px 16px 0; display: grid; gap: 8px; }
.errorlist { color: var(--danger-ink); list-style: none; padding: 0; margin: 4px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
table { width: 100%; border-collapse: collapse; } td, th { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: .88rem; }

/* Строка поиска + кнопка «Фильтры», раскрывающая панель (списки заявок, фирм) */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 10px; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; flex: none; min-height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.filters { margin-bottom: 12px; }
.filters .row { flex-wrap: nowrap; gap: 6px; }
.filters input[type=search] { flex: 1; min-width: 0; }
.filters select, .filters input, .filters button, .filters .btn { min-height: 40px; }
.filters .row button { padding: 0 12px; flex: none; }
.filters svg { width: 18px; height: 18px; }
.filters .count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: var(--brand-text); font-size: .75rem; }
.more { display: grid; gap: 8px; margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.more[hidden] { display: none; }
.more .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.more .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more .actions .btn { padding: 0 10px; font-size: .93rem; text-align: center; }
/* строка-ссылка в списках (сотрудники, фирмы) */
.item, a.card.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.item .body { flex: 1; min-width: 0; }
.item .go { color: var(--muted); flex: none; }
