/* Bargain CRM — стиль по мотивам bargainstore.tech: Manrope, графит, светло-серые плашки, «таблетки» */
:root {
  --ink: #3e3e3e;
  --ink-strong: #222;
  --muted: #909090;
  --line: #ececec;
  --surface: #f6f6f6;
  --surface-2: #efefef;
  --bg: #ffffff;
  --green: #2ba36b;
  --green-bg: #e8f6ef;
  --red: #d9534f;
  --red-bg: #fcebea;
  --amber: #c98a00;
  --amber-bg: #fdf4dc;
  --blue: #3e7bfa;
  --r-card: 24px;
  --r-field: 14px;
  --r-pill: 200px;
  --sidebar: 252px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .08);
  font-family: Manrope, Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Каркас ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 16px 16px;
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; }
.brand b { font-size: 21px; font-weight: 600; letter-spacing: -.02em; color: var(--ink); }
.brand span { font-size: 11px; font-weight: 600; background: var(--ink); color: #fff; border-radius: var(--r-pill); padding: 2px 8px; }
.nav-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-pill);
  text-decoration: none; font-weight: 500; color: var(--ink); transition: background .15s;
}
.nav a:hover { background: var(--surface); }
.nav a.active { background: var(--ink); color: #fff; }
.nav a .badge { margin-left: auto; font-size: 11px; background: var(--surface-2); color: var(--ink); border-radius: var(--r-pill); padding: 1px 8px; }
.nav a.active .badge { background: rgba(255,255,255,.18); color: #fff; }
.sidebar .me { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--line); }
.sidebar .me b { display: block; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 24px; }
.topbar .spacer { flex: 1; }
.topbar .burger { display: none; }
.content { padding: 24px 28px 60px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 20px;
  border: 0; border-radius: var(--r-pill); background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.light { background: var(--surface); color: var(--ink); }
.btn.light:hover { background: var(--surface-2); opacity: 1; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.green { background: var(--green); }
.btn.sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.icon { width: 42px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn .arrow { display: grid; place-items: center; width: 30px; height: 30px; margin-right: -14px; border-radius: 50%; background: #fff; color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--r-field);
  background: var(--surface); outline: none; transition: border-color .15s, background .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--ink); background-color: #fff; }
select.input { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23909090' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 12px; color: var(--muted); }
.search .input { padding-left: 40px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Карточки ---------- */
.card { background: var(--surface); border-radius: var(--r-card); padding: 22px; }
.card.white { background: #fff; border: 1px solid var(--line); }
.card h2 { font-size: 18px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border-radius: var(--r-card); padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; min-height: 128px; position: relative; overflow: hidden; }
.kpi .label { font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-top: auto; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.dark { background: var(--ink); color: #fff; }
.kpi.dark .label, .kpi.dark .sub { color: rgba(255,255,255,.65); }
.kpi.link { cursor: pointer; transition: transform .15s; }
.kpi.link:hover { transform: translateY(-2px); }
.kpi .corner { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; }
.kpi.dark .corner { background: #fff; color: var(--ink); }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff; position: sticky; top: 0; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #fafafa; }
.t td.r, .t th.r { text-align: right; }
.t .title { font-weight: 600; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Чипы и бейджи ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: var(--r-pill);
  background: var(--surface); border: 0; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.chip.active { background: var(--ink); color: #fff; }
.chip .n { font-size: 12px; opacity: .6; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; background: #fff; border: 1px solid var(--line); white-space: nowrap; }
.tag.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.tag.green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.tag.red { background: var(--red-bg); color: var(--red); border-color: transparent; }
.tag.amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.tag.gray { background: var(--surface); border-color: transparent; color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Канбан ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.col { flex: 0 0 290px; background: var(--surface); border-radius: var(--r-card); padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 230px); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 2px; font-weight: 600; }
.col-head .n { margin-left: auto; color: var(--muted); font-weight: 500; }
.col-body { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 80px; padding: 2px; border-radius: 16px; transition: background .15s; }
.col-body.over { background: var(--surface-2); }
.col-more { text-align: center; }
.lead {
  background: #fff; border-radius: 18px; padding: 14px; cursor: grab; display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); border: 1px solid transparent; transition: border-color .15s, opacity .15s;
}
.lead:hover { border-color: var(--line); }
.lead.dragging { opacity: .4; }
.lead.due { border-color: var(--amber); }
.lead .name { font-weight: 600; }
.lead .dev { font-size: 13px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lead .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.lead-list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Модальные окна ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30,30,30,.45); z-index: 100; display: flex; justify-content: flex-end; animation: fade .15s; }
.overlay.center { justify-content: center; align-items: center; padding: 20px; }
.drawer { width: min(620px, 100%); height: 100%; background: #fff; overflow-y: auto; padding: 26px; display: flex; flex-direction: column; gap: 18px; animation: slide .2s ease-out; }
.dialog { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; background: #fff; border-radius: var(--r-card); padding: 26px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; }
.modal-head h2 { font-size: 22px; flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline .item { background: var(--surface); border-radius: 14px; padding: 10px 14px; }
.timeline .item .when { font-size: 12px; color: var(--muted); }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--r-pill); box-shadow: var(--shadow); animation: fade .2s; max-width: 90vw; }
.toast.err { background: var(--red); }
.toast.warn { background: var(--amber); }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .hero { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 0 32px 32px 0; }
.login .hero h1 { font-size: 44px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; max-width: 460px; }
.login .hero .tags { display: flex; gap: 8px; }
.login .hero .tags span { border: 1px solid rgba(255,255,255,.3); border-radius: var(--r-pill); padding: 6px 14px; font-size: 13px; }
.login form { align-self: center; justify-self: center; width: min(380px, 90vw); display: flex; flex-direction: column; gap: 14px; }
.login form h2 { font-size: 28px; margin-bottom: 6px; }

/* ---------- Смены ---------- */
.shifts { border-collapse: separate; border-spacing: 3px; }
.shifts th { font-size: 11px; color: var(--muted); font-weight: 500; padding: 4px; }
.shifts th.we { color: var(--red); }
.shifts td.cell { width: 30px; height: 30px; border-radius: 9px; background: var(--surface); text-align: center; cursor: pointer; font-size: 11px; }
.shifts td.cell.on { background: var(--ink); color: #fff; }
.shifts td.cell.ro { cursor: default; }
.shifts td.name { padding-right: 10px; white-space: nowrap; font-weight: 500; }

.bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: 12px; padding: 6px 0; }

.no-access { text-align: center; padding: 80px 20px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 20px; }
  .topbar .burger { display: inline-flex; }
  .topbar .who { display: none; }
  .content { padding: 16px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login .hero { border-radius: 0 0 28px 28px; padding: 28px; gap: 28px; }
  .login .hero h1 { font-size: 30px; }
  .login form { padding: 28px 0; }
  .kpi .value { font-size: 24px; }
  .drawer { padding: 18px; }
  .funnel-row { grid-template-columns: 100px 1fr 40px; }
}

/* ---------- Печать ---------- */
@media print {
  body { font-size: 12px; }
}
