:root { --sidebar-w: 236px; --brand: #8a5a00; --bs-body-font-size: .9rem; }
body { background: #f4f5f7; }
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #1f2430; color: #c9ced8; flex-shrink: 0; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; padding-bottom: 2rem; z-index: 1030; }
.sidebar .brand { display: block; padding: 14px 18px; font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none;
  border-bottom: 1px solid #2d3343; }
.sidebar .brand i { color: #f2b544; }
.sidebar .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #7d8597; padding: 14px 18px 4px; }
.sidebar .nav-link { color: #c9ced8; padding: 5px 18px; font-size: .87rem; display: block; }
.sidebar .nav-link i { width: 20px; display: inline-block; opacity: .85; }
.sidebar .nav-link:hover { color: #fff; background: #2a3040; }
.sidebar .nav-link.active { color: #fff; background: #343b4f; border-left: 3px solid #f2b544; padding-left: 15px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e3e6eb; padding: 8px 20px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 1020; }
.topbar .search { position: relative; flex: 1; max-width: 520px; }
.topbar .search i { position: absolute; left: 10px; top: 6px; color: #8a93a3; }
.topbar .search input { padding-left: 30px; }
.content { padding: 18px 22px 40px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 1.35rem; margin: 0; font-weight: 600; }
.page-head .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.card { border: 1px solid #e3e6eb; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-header { background: #fff; font-weight: 600; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table-crm { background: #fff; font-size: .86rem; }
.table-crm thead th { background: #f8f9fb; font-weight: 600; color: #4b5363; font-size: .8rem; vertical-align: bottom;
  border-bottom-width: 1px; position: sticky; top: 0; }
.table-crm td { vertical-align: middle; }
.table-crm tr.clickable { cursor: pointer; }
.table-crm tr.clickable:hover td { background: #f5f8ff; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge-status { font-weight: 500; }
.text-bg-orange { background: #fd7e14 !important; color: #fff !important; }
.text-bg-purple { background: #6f42c1 !important; color: #fff !important; }
.text-bg-teal { background: #20c997 !important; color: #fff !important; }
.kpi { background: #fff; border: 1px solid #e3e6eb; border-radius: .5rem; padding: 12px 14px; height: 100%; }
.kpi .label { font-size: .75rem; color: #6c757d; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: #6c757d; }
.dl-grid { display: grid; grid-template-columns: 190px 1fr; gap: 4px 12px; font-size: .88rem; }
.dl-grid dt { color: #6c757d; font-weight: 400; }
.dl-grid dd { margin: 0; }
.signal { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #eef0f3; font-size: .87rem; }
.signal:last-child { border-bottom: 0; }
.signal .ico { font-size: 1.1rem; }
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.board-col { min-width: 250px; width: 250px; background: #eceef2; border-radius: .5rem; padding: 8px; flex-shrink: 0; }
.board-col h6 { font-size: .8rem; text-transform: uppercase; color: #4b5363; display: flex; flex-direction: column; gap: 2px; min-height: 2.6rem; }
.board-col h6 .board-sum { text-transform: none; font-weight: 400; color: #6c757d; font-size: .76rem; }
.board-card { background: #fff; border-radius: .4rem; padding: 8px 10px; margin-bottom: 8px; font-size: .82rem;
  border: 1px solid #e1e4ea; cursor: grab; display: block; color: inherit; text-decoration: none; }
.board-card:hover { border-color: #9db4e8; }
.board-card.drag-over { outline: 2px dashed #6c8fd8; }
.board-col.drag-over { background: #dde5f5; }
.funnel { display: flex; gap: 2px; margin-bottom: 12px; }
.funnel .step { flex: 1; text-align: center; padding: 6px 4px; background: #e9ecef; font-size: .78rem; color: #6c757d;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); }
.funnel .step:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); }
.funnel .step.done { background: #cfe2d6; color: #1f5132; }
.funnel .step.current { background: #0d6efd; color: #fff; font-weight: 600; }
button.funnel-btn { border: 0; background: none; padding: 0; width: 100%; color: inherit; font: inherit; }
.progress-thin { height: 6px; }
.form-label { font-size: .82rem; margin-bottom: 2px; color: #4b5363; }
.form-text { font-size: .74rem; }
.formset-row td { padding: 4px; }
.history-diff { font-size: .82rem; }
.muted-small { font-size: .78rem; color: #6c757d; }
.filters .form-select, .filters .form-control { width: auto; min-width: 140px; }
@media (max-width: 991px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 12px; }
  .dl-grid { grid-template-columns: 1fr; }
}
@media print { .sidebar, .topbar, .actions, .no-print { display: none !important; } .content { padding: 0; } }
.signal a { text-decoration: none; } .signal a:hover { text-decoration: underline; }
.page-head .actions .form-select { width: auto; }
#items-rows .form-control, #items-rows .form-select { font-size: .84rem; padding-top: .25rem; padding-bottom: .25rem; }
#items-rows .form-select { padding-left: .5rem; padding-right: 1.6rem; background-position: right .4rem center; }
#items-rows td { padding: 4px 3px; }
/* Товари в угоді: картка на рядок замість широкої таблиці */
#items-rows { counter-reset: item; display: flex; flex-direction: column; gap: .85rem; padding: 1rem; }
#items-rows .item-row { counter-increment: item; padding: 1rem 1.25rem 1.1rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); }
#items-rows .item-row:nth-child(even) { background: var(--bs-tertiary-bg); }
#items-rows .item-row .row { --bs-gutter-y: .75rem; }
#items-rows .item-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--bs-border-color); font-size: .84rem; }
#items-rows .item-no::before { content: "Товар " counter(item); font-weight: 600; }
#items-rows .item-del, #items-rows .item-undo { padding: .1rem .5rem; font-size: .8rem; }
#items-rows .item-undo, #items-rows .item-deleted-msg { display: none; }
#items-rows .item-row.is-deleted { counter-increment: none; opacity: .65; border-style: dashed; background: none; padding-bottom: .6rem; }
#items-rows .item-row.is-deleted .item-head { margin: 0; padding: 0; border: 0; }
#items-rows .item-row.is-deleted :is(.item-body, .item-no, .line-sum, .item-del) { display: none; }
#items-rows .item-row.is-deleted :is(.item-undo, .item-deleted-msg) { display: inline-block; }
#items-rows .item-deleted-msg { color: var(--bs-secondary-color); font-style: italic; }
#items-rows .item-label { display: block; font-size: .75rem; color: var(--bs-secondary-color); margin-bottom: .15rem; }
#items-rows .qty-group .form-control { min-width: 0; }
#items-rows .qty-group .form-select { flex: 0 0 5.2rem; width: 5.2rem; }
#items-rows .free { color: var(--bs-success-text-emphasis); }
.items-total { padding: .25rem 1.25rem 1rem; text-align: right; }
.form-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; font-weight: 600;
  margin: 1.4rem 0 .6rem; padding-bottom: .35rem; border-bottom: 1px solid #e3e6eb; }
.filters .form-select { max-width: 280px; }
/* жовті контурні кнопки: темніший текст, щоб читалися на білому */
.btn-outline-warning { --bs-btn-color: #8a6100; --bs-btn-border-color: #e0a800; --bs-btn-hover-color: #000; }
/* кнопка у flex-рядку не розтягується на висоту сусіднього блоку */
.d-flex:not(.flex-column) > .btn, .d-flex:not(.flex-column) > form > .btn { align-self: center; }
.btn { white-space: nowrap; }

/* ── Гонка місяця: рейтинг менеджерів на «Головній» ── */
.race { --gold: #f2b544; --gold-2: #d4911b; --silver: #c3cad6; --silver-2: #8e97a6; --bronze: #d8955c; --bronze-2: #a8642d;
  background: #fff; border: 1px solid #e3e6eb; border-radius: .75rem; overflow: hidden; }
.race-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; padding: 16px 20px;
  background: radial-gradient(circle at 90% -40%, rgba(242,181,68,.35), transparent 55%), linear-gradient(135deg, #1f2430, #343b4f);
  color: #fff; }
.race-title { font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; }
.race-title i { color: var(--gold); margin-right: 4px; }
.race-sub { font-size: .8rem; color: #b8bfcc; }
.race-me { margin-left: auto; display: flex; flex-direction: column; gap: 2px; min-width: 240px; max-width: 360px;
  padding: 10px 14px; border-radius: .6rem; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
  font-size: .82rem; color: #dfe3ea; }
.race-me b { color: #fff; }
.race-me-big { font-size: 1rem; font-weight: 700; color: #fff; }
.race-me-sub { font-size: .72rem; color: #b8bfcc; }
.race-me.is-leader { background: linear-gradient(135deg, rgba(242,181,68,.35), rgba(242,181,68,.12)); border-color: var(--gold); }
.race-me .race-track { background: rgba(255,255,255,.15); }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; padding: 22px 20px 0;
  max-width: 760px; margin: 0 auto; }
.pod { text-align: center; position: relative; min-width: 0; }
.pod-crown { height: 30px; font-size: 1.6rem; line-height: 30px; animation: crown 2.4s ease-in-out infinite; }
@keyframes crown { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-4px) rotate(6deg); } }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; background: #6b7385; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ring, #d5d9e0); }
.avatar.sm { width: 32px; height: 32px; font-size: .75rem; box-shadow: none; flex-shrink: 0; }
.pod-1 .avatar { width: 72px; height: 72px; font-size: 1.4rem; background: linear-gradient(135deg, var(--gold), var(--gold-2)); --ring: var(--gold); }
.pod-2 .avatar { background: linear-gradient(135deg, var(--silver), var(--silver-2)); --ring: var(--silver); }
.pod-3 .avatar { background: linear-gradient(135deg, var(--bronze), var(--bronze-2)); --ring: var(--bronze); }
.pod-name { margin-top: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-profit { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pod-1 .pod-profit { font-size: 1.45rem; color: var(--gold-2); }
.pod-profit small { font-size: .7em; font-weight: 500; color: #6c757d; }
.pod-meta { font-size: .75rem; color: #6c757d; margin-bottom: 8px; }
.pedestal { border-radius: .5rem .5rem 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px;
  font-size: 1.6rem; font-weight: 800; color: rgba(255,255,255,.95); text-shadow: 0 1px 2px rgba(0,0,0,.2); position: relative; overflow: hidden; }
.pod-1 .pedestal { height: 96px; background: linear-gradient(180deg, var(--gold), var(--gold-2)); }
.pod-2 .pedestal { height: 66px; background: linear-gradient(180deg, var(--silver), var(--silver-2)); }
.pod-3 .pedestal { height: 46px; background: linear-gradient(180deg, var(--bronze), var(--bronze-2)); }
.pod-1 .pedestal::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%); animation: shine 3.5s ease-in-out infinite; }
@keyframes shine { 0%, 55% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.pod.is-empty .avatar { background: #c9ced8; }
.pod.is-empty .pod-profit { color: #adb5bd; }
.pod.is-me .pod-name { color: var(--brand); }
.you { display: inline-block; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px;
  border-radius: 1rem; background: var(--brand); color: #fff; vertical-align: middle; }

.race-list { border-top: 1px solid #e3e6eb; padding: 6px 20px; }
.race-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: .5rem; }
.race-row.is-me { background: #fff6e2; box-shadow: inset 3px 0 0 var(--gold); }
.race-place { width: 22px; text-align: center; font-weight: 700; color: #6c757d; }
.race-gap { width: 92px; text-align: right; font-size: .78rem; color: #6c757d; font-variant-numeric: tabular-nums; }
.race-track { height: 6px; border-radius: 3px; background: #edf0f4; margin-top: 4px; overflow: hidden; }
.race-bar { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #6f86d6, #48c6ef); transition: width .6s ease; }
.race-me .race-bar { background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.race-foot { padding: 8px 20px 12px; font-size: .75rem; color: #8a93a3; border-top: 1px solid #f0f2f5; }
.min-w-0 { min-width: 0; }
@media (max-width: 576px) {
  .race-me { margin-left: 0; max-width: none; width: 100%; }
  .podium { gap: 6px; padding: 18px 10px 0; }
  .avatar { width: 40px; height: 40px; font-size: .85rem; }
  .pod-1 .avatar { width: 54px; height: 54px; font-size: 1.1rem; }
  .pod-profit { font-size: .95rem; } .pod-1 .pod-profit { font-size: 1.1rem; }
  .pod-name { font-size: .8rem; white-space: normal; overflow-wrap: anywhere; }
  .race-list { padding: 6px 8px; } .race-gap { width: 70px; }
}
@media (prefers-reduced-motion: reduce) { .pod-crown, .pod-1 .pedestal::after { animation: none; } }
