:root {
  --bg: #f6f6f4; --card: #fff; --line: #e3e2dd; --text: #22221f; --muted: #6b6a64;
  --accent: #185fa5; --accent-bg: #e6f1fb;
  --warn: #854f0b; --warn-bg: #faeeda; --warn-line: #ef9f27;
  --err: #a32d2d; --err-bg: #fcebeb; --ok: #3b6d11; --ok-bg: #eaf3de;
  --radius: 8px; --panel-w: 460px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 18px; font-weight: 600; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0; }
h3 { margin: 0 0 12px; font-size: 16px; }
h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; background: #fff; width: 100%; }
textarea { resize: vertical; }
/* выпадающие списки: своя стрелка с отступом от края */
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b6a64' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
label { display: block; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 3px; color: var(--text); font-size: 14px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
label.check input { width: auto; margin: 0; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.sub, .hint { color: var(--muted); font-size: 12px; }
.hint { margin: 4px 0; }

.btn { display: inline-block; border: 1px solid #cfcdc6; background: #fff; border-radius: var(--radius); padding: 6px 12px; cursor: pointer; font: inherit; color: var(--text); white-space: nowrap; }
.btn:hover { background: #f1f0ec; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.row { display: flex; gap: 8px; align-items: flex-start; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* шапка */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 10px; border-radius: var(--radius); color: var(--muted); }
.top nav a.on { background: var(--accent-bg); color: var(--accent); }
.top .find { margin-left: auto; position: relative; }
.find-box { display: flex; gap: 6px; }
.find-box input { width: clamp(160px, 26vw, 320px); }
.top nav a, .top .me, button.link { white-space: nowrap; }
@media (max-width: 1000px) {
  .brand { display: none; }
  .top { gap: 10px; padding: 10px 12px; }
}
.find-err { position: absolute; top: 100%; left: 0; margin-top: 4px; font-size: 12px; color: var(--err); white-space: nowrap; }
.find-err:empty { display: none; }
input[readonly] { background: #f6f6f4; color: var(--muted); }
.top .me { color: var(--muted); }
.messages { padding: 8px 20px 0; }
.msg { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 6px; background: var(--accent-bg); color: var(--accent); }
.msg.error { background: var(--err-bg); color: var(--err); }
.msg.success { background: var(--ok-bg); color: var(--ok); }

/* раскладка: контент + панель карточки справа */
.layout { display: flex; align-items: flex-start; }
main { flex: 1; min-width: 0; padding: 16px 20px; }
.panel { display: none; width: var(--panel-w); flex: 0 0 var(--panel-w); background: #fff; border-left: 1px solid var(--line); height: calc(100vh - 53px); position: sticky; top: 53px; overflow-y: auto; }
.panel.open { display: block; }

/* дашборд */
.board-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.depts { display: flex; gap: 6px; margin-left: auto; }
.chip { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; background: #fff; }
.chip.on { background: var(--accent-bg); color: var(--accent); border-color: #85b7eb; }
.board { display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.col { flex: 0 0 200px; width: 200px; background: #ecebe6; border-radius: 12px; padding: 8px; }
.col.me { outline: 2px solid #85b7eb; }
.col-head { display: flex; justify-content: space-between; gap: 6px; margin: 2px 2px 8px; }
.col-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cnt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cnt b { color: var(--warn); }
.tile { display: flex; justify-content: space-between; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; margin-bottom: 6px; color: var(--text); cursor: pointer; }
.tile:hover { border-color: #b4b2a9; }
.tile.needs { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ico { font-weight: 700; width: 18px; height: 18px; border-radius: 50%; background: var(--warn-line); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 18px; }
.empty { color: var(--muted); padding: 24px; }

/* статусы */
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: var(--radius); white-space: nowrap; }
.badge.free { background: #f1efe8; color: #5f5e5a; border: 1px solid var(--line); }
.badge.work { background: var(--accent-bg); color: var(--accent); }
.badge.needs { background: var(--warn-bg); color: var(--warn); }
.badge.small { font-size: 11px; padding: 1px 6px; }

/* панель карточки */
.pn { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.pn-head { display: flex; justify-content: space-between; gap: 8px; }
.cid { display: flex; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; font-size: 12px; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.pn-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner { padding: 8px 10px; border-radius: var(--radius); font-size: 13px; }
.banner.needs { background: var(--warn-bg); color: var(--warn); }
.banner.err { background: var(--err-bg); color: var(--err); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions:empty { display: none; }
details.act > summary { list-style: none; display: inline-block; }
details.act > summary::-webkit-details-marker { display: none; }
details.act[open] { background: #faf9f6; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
details.act[open] > summary { margin-bottom: 8px; }
.fields { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.fields .btn { align-self: flex-start; }
.linked, .feed { border-top: 1px solid var(--line); padding-top: 12px; }
.lrow { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.lrow form { margin-left: auto; }
.linked .row { margin-top: 6px; }
.feed .row { margin-bottom: 8px; }
.ev { padding: 8px 0; border-top: 1px solid #efeee9; font-size: 13px; }
.ev-text { margin-top: 2px; white-space: normal; overflow-wrap: anywhere; }
.ev-needs, .ev-reminder { background: #fffaf1; }

/* все чаты */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.filters input[type=search] { width: 240px; }
.filters select { width: auto; min-width: 170px; }
.bulkbar { display: flex; gap: 8px; align-items: center; background: #ecebe6; padding: 6px 10px; border-radius: var(--radius); margin-bottom: 6px; flex-wrap: wrap; }
.bulkbar select, .bulkbar input { width: auto; padding-top: 4px; padding-bottom: 4px; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid #efeee9; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #faf9f6; }
.tbl input[type=checkbox] { width: auto; }
.r-needs { background: #fffaf1; }
.pager { display: flex; gap: 16px; justify-content: center; padding: 12px; }

/* вход и диалог */
.login { max-width: 420px; margin: 60px auto; background: #fff; padding: 24px; border-radius: 12px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 520px; max-width: 95vw; }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog::backdrop { background: rgba(0,0,0,.35); }

/* настройки Ozon */
.settings { max-width: 560px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.banner { background: #f1efe8; color: var(--muted); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.checks { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.checks .ok b { color: var(--ok); }
.checks .err b { color: var(--err); }
.check-result { border-top: 1px solid var(--line); padding-top: 12px; }
