:root {
  --bg: #191d26; --panel: #212633; --panel2: #2a3040; --line: #3a4152;
  --text: #eaecf2; --muted: #9aa2b3; --accent: #6ea8fe; --accent2: #3a6fd0;
  --pos: #35c98a; --neg: #ff6b6b; --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text);
  background:
    radial-gradient(1100px 560px at 74% -10%, rgba(139, 92, 246, .16), transparent 60%),
    radial-gradient(820px 460px at 6% -6%, rgba(79, 140, 255, .11), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 18px 0; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; justify-content: center; padding: 8px 12px 18px; }

/* Логотип METRICS (прозрачный PNG) */
.mx-img { display: block; height: auto; }
.mx-md { width: 162px; filter: drop-shadow(0 6px 18px rgba(139,92,246,.28)); }   /* сайдбар */
.mx-lg { width: 250px; filter: drop-shadow(0 8px 26px rgba(139,92,246,.38)); }   /* вход */
.auth-logo { display: flex; justify-content: center; margin-bottom: 4px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 11px 20px;
  color: var(--muted); font-size: 14px; font-weight: 500; border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.sidebar nav a.active { color: var(--text); background: var(--panel2); border-left-color: var(--accent); }
.sidebar nav a .ic { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.sidebar nav a .ic svg { width: 18px; height: 18px; display: block; }
.sidebar-foot { margin-top: auto; padding: 16px 20px 4px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.sidebar-foot .who { display: flex; flex-direction: column; font-size: 14px; color: var(--text); }
.sidebar-foot .who span { color: var(--muted); font-size: 12px; }

.content { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.content--plain { display: block; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; }
  .sidebar .brand { padding: 0 12px 0 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .sidebar nav a.active { border-left: 0; border-bottom-color: var(--accent); }
  .sidebar-foot { margin-top: 0; margin-left: auto; border-top: 0; flex-direction: row; align-items: center; padding: 0; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 30px 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

.btn, button.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0;
  padding: 9px 16px; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { background: var(--accent2); text-decoration: none; }
.btn-ghost {
  display: inline-block; background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; margin-bottom: 26px; }

/* Legacy simple card (используется на старой странице свода) */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card b { font-size: 20px; }
.card.pos b { color: var(--pos); }
.card.neg b { color: var(--neg); }

/* Цветные карточки-метрики */
.stat {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-radius: 16px; padding: 16px 18px; color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.22);
}
.stat .s-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; opacity: .9; }
.stat .s-value { font-size: 27px; font-weight: 700; margin-top: 7px; line-height: 1.05; }
.stat .s-sub { font-size: 11.5px; opacity: .85; margin-top: 5px; }
.stat .s-ic { width: 46px; height: 46px; border-radius: 13px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat .s-ic svg { width: 23px; height: 23px; }

.stat--cost { background: linear-gradient(135deg, #f6b83c, #e39c05); color: #2c2200; }
.stat--cost .s-ic { background: rgba(0,0,0,.14); }
.stat--dep  { background: linear-gradient(135deg, #4a90ff, #2f6fe0); }
.stat--rev  { background: linear-gradient(135deg, #46586f, #33475e); }
.stat--profit-pos { background: linear-gradient(135deg, #2fc48f, #1f9c72); }
.stat--profit-neg { background: linear-gradient(135deg, #ff7a7a, #e24b4b); }
.stat--roi  { background: linear-gradient(135deg, #6b5bd0, #4b3fae); }
.stat--slate { background: linear-gradient(135deg, #46586f, #33475e); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.015); }
tbody tr:hover { background: var(--panel2); }
tbody td:first-child { font-weight: 500; }
td.r, th.r { text-align: right; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* Стильные градиентные плашки в ячейках */
.pill {
  display: inline-block; min-width: 62px; padding: 5px 13px; border-radius: 9px;
  font-weight: 600; font-size: 13.5px; text-align: center; letter-spacing: .01em;
  transition: transform .12s ease;
}
tbody tr:hover .pill { transform: translateY(-1px); }
.pill-cost { background: linear-gradient(135deg, #f7bd45, #e3a010); color: #2b2100; box-shadow: 0 2px 10px rgba(227,160,16,.25); }
.pill-dep { background: linear-gradient(135deg, #4f93ff, #2f6fe0); color: #fff; box-shadow: 0 2px 10px rgba(47,111,224,.28); }
.pill-profit-pos { background: linear-gradient(135deg, #35cd93, #1f9c72); color: #fff; box-shadow: 0 2px 10px rgba(31,156,114,.3); }
.pill-profit-neg { background: linear-gradient(135deg, #ff8080, #e24b4b); color: #fff; box-shadow: 0 2px 10px rgba(226,75,75,.3); }
.pill-muted { background: rgba(255,255,255,.06); color: var(--muted); box-shadow: none; }
.sub-late { font-size: 11px; color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

/* Чип-кнопки управления юзером */
.act { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 13px; font-weight: 500; line-height: 1; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.act svg { width: 14px; height: 14px; flex: none; }
.act:hover { border-color: var(--accent); color: #fff; }
.act-primary { border-color: transparent; background: rgba(110,168,254,.18); color: #cfe0ff; }
.act-primary:hover { background: rgba(110,168,254,.30); color: #fff; }
.act-warn:hover { border-color: #e0a94a; color: #ffd699; background: rgba(224,169,74,.14); }
.act-ok { color: #7fe0b0; }
.act-ok:hover { border-color: var(--pos); background: rgba(53,201,138,.14); color: #fff; }
.act-danger { color: var(--neg); padding: 7px 9px; }
.act-danger:hover { border-color: var(--neg); background: rgba(255,107,107,.16); color: #fff; }
.link-danger { background: none; border: 0; color: var(--neg); cursor: pointer; font-size: 15px; padding: 0; }

.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.b-approve { color: var(--pos); border-color: var(--pos); }
.b-reject { color: var(--neg); border-color: var(--neg); }
.b-hold { color: #e6b800; border-color: #e6b800; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 640px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; }

/* Декоративный фон-графики на странице входа */
.auth-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.auth-bg svg { width: 100%; height: 100%; display: block; }
.ag-float { animation: agFloat 13s ease-in-out infinite alternate; }
@keyframes agFloat { from { transform: translateY(6px); } to { transform: translateY(-14px); } }
.ag-line-b { stroke-dasharray: 2700; stroke-dashoffset: 2700; animation: agDraw 10s ease-in-out infinite; }
@keyframes agDraw { 0% { stroke-dashoffset: 2700; } 55% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .ag-float, .ag-line-b { animation: none; } }

.auth-card {
  position: relative; z-index: 1;
  max-width: 340px; margin: 80px auto; background: rgba(30, 34, 46, .72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45), 0 0 0 1px rgba(139, 92, 246, .06);
}
.auth-card h1 { margin: 0 0 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.auth-card input[type="text"], .auth-card input[type="password"], .auth-card input:not([type]) {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus { outline: none; border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,.22); }
.auth-card button[type="submit"] {
  margin-top: 8px; width: 100%; border: 0; cursor: pointer;
  padding: 13px 18px; border-radius: 12px; font-size: 15px; font-weight: 700; letter-spacing: .02em; color: #fff;
  background: linear-gradient(100deg, #7c3aed 0%, #6d5cf6 45%, #6ea8fe 100%);
  box-shadow: 0 10px 26px rgba(124,58,237,.38);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.auth-card button[type="submit"]:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 15px 36px rgba(124,58,237,.52); }
.auth-card button[type="submit"]:active { transform: translateY(0); box-shadow: 0 8px 20px rgba(124,58,237,.42); }

.alert { background: rgba(255,107,107,.12); border: 1px solid var(--neg); color: #ffb3b3; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-ok { background: rgba(53,201,138,.12); border: 1px solid var(--pos); color: #9fe8c6; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel2); }
tr.hidden { display: none; }
tr.expandable { cursor: pointer; }
tr.row-geo { background: rgba(255,255,255,.022); }
tr.row-offer { background: rgba(255,255,255,.045); }
.lvl-camp { font-weight: 500; }
.lvl-geo { padding-left: 30px !important; }
.lvl-offer { padding-left: 58px !important; color: var(--muted); }
.caret { display: inline-block; width: 14px; color: var(--muted); transition: transform .12s; font-size: 11px; }
tr.open .caret { transform: rotate(90deg); }
.crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--accent); }
.crumbs a:hover { text-decoration: underline; }
.crumbs b { color: var(--text); }
.datenav { display: flex; align-items: center; gap: 8px; }
.datenav input[type=date] { text-align: center; }
.filter-box { width: 100%; margin-bottom: 14px; }
.spend-inp { width: 90px; text-align: right; padding: 6px 8px; border: 1.5px solid #c9a227; border-radius: 8px; background: rgba(201,162,39,.05); color: var(--text); }
.spend-inp::placeholder { color: rgba(201,162,39,.5); }
.spend-inp:focus { outline: none; border-color: #e0b83a; background: rgba(201,162,39,.09); box-shadow: 0 0 0 3px rgba(201,162,39,.16); }
.cost-cell { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.cost-add { width: 28px; height: 32px; border-radius: 7px; border: 1.5px solid #c9a227; background: rgba(201,162,39,.06); color: #d4af37; font-size: 18px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.cost-add:hover { border-color: #e0b83a; background: rgba(201,162,39,.14); color: #e0b83a; }
.cost-cell.saved input { border-color: var(--pos); }
.cost-cell.saved .cost-add { border-color: var(--pos); color: var(--pos); }

.toolbar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.toolbar .tb-right { margin-left: auto; display: flex; gap: 12px; align-items: flex-end; }
.segmented { display: inline-flex; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.segmented a { display: flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px; color: var(--muted); font-size: 14px; font-weight: 600; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: #fff; color: #1a1d24; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.segmented a .ic { display: inline-flex; width: 16px; height: 16px; }
.segmented a .ic svg { width: 16px; height: 16px; }
.grp-cell { white-space: normal; max-width: 360px; line-height: 1.35; }

.daterange { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.daterange label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.presets { display: flex; gap: 6px; align-items: center; }
.preset { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; background: var(--panel2); white-space: nowrap; }
.preset:hover { color: var(--text); text-decoration: none; border-color: var(--muted); }
.preset.active { background: #fff; color: #1a1d24; border-color: #fff; font-weight: 600; }
.flag { width: 22px; height: 16px; border-radius: 3px; margin-right: 9px; vertical-align: -3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.1); }

.btn-ic { display: inline-flex; width: 15px; height: 15px; vertical-align: -2px; margin-right: 5px; }
.btn-ic svg { width: 15px; height: 15px; }
.tag-chip { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; font-size: 12px; }

/* Модальное окно */
.modal-overlay { position: fixed; inset: 0; background: rgba(6,8,12,.66); display: none; align-items: flex-start; justify-content: center; z-index: 200; padding: 64px 16px; overflow: auto; }
.modal-overlay.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 440px; box-shadow: 0 24px 70px rgba(0,0,0,.55); overflow: hidden; }
.modal-tabs { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-tabs .mt { display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.modal-tabs .mt:hover { color: var(--text); }
.modal-tabs .mt.active { background: #fff; color: #1a1d24; }
.modal-tabs .mt-ic { display: inline-flex; width: 15px; height: 15px; }
.modal-tabs .mt-ic svg { width: 15px; height: 15px; }
.modal-x { margin-left: auto; background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.modal-body input {
  background-color: var(--panel2);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a92a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 34px;
}
.modal-body input::-webkit-calendar-picker-indicator { opacity: 0; }
.modal-foot { display: flex; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); }
.btn-blue { background: var(--accent); color: #fff; border: 0; padding: 12px 18px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 15px; width: 100%; }
.btn-blue:hover { background: var(--accent2); }
.modal-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 2px 0; }
.tag-regs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.tag-reg { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 5px 10px 5px 6px; font-size: 13px; }
.tag-reg form { margin: 0; }
.tag-reg.off { opacity: .5; }
.tag-switch { width: 32px; height: 18px; border-radius: 10px; border: 0; background: var(--line); position: relative; cursor: pointer; padding: 0; flex-shrink: 0; }
.tag-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.tag-switch.on { background: var(--pos); }
.tag-switch.on::after { left: 16px; }
.no-chev { background-image: none !important; padding-right: 13px !important; }
.tag-input { text-transform: uppercase; letter-spacing: 5px; font-size: 18px; font-weight: 700; text-align: center; }

/* Панель создания байера */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 22px; }
.cb-grid { display: grid; grid-template-columns: 120px 1fr 1fr 1.3fr 150px auto; gap: 14px; align-items: end; }
.cb-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.cb-submit { display: flex; align-items: flex-end; }
.pass-wrap { display: flex; gap: 6px; }
.pass-wrap input { flex: 1; min-width: 0; }
.btn-ghost.mini { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
.link-btn { background: transparent; border: 0; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
@media (max-width: 900px) { .cb-grid { grid-template-columns: 1fr 1fr; } .cb-submit { grid-column: 1 / -1; } }

/* Аватарки */
.ava { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; flex-shrink: 0; overflow: hidden; font-weight: 700; color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.1); }
.ava-sm { width: 26px; height: 26px; font-size: 12px; }
.ava-md { width: 40px; height: 40px; font-size: 16px; }
.ava-lg { width: 96px; height: 96px; font-size: 40px; }
.ava-letter { text-transform: uppercase; }
td .ava-sm { vertical-align: -8px; margin-right: 8px; }
.grp-name { font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 3px; }
.bsel-btn .ava-sm, .bsel-menu .ava-sm { box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.ava-edit { position: relative; display: inline-flex; cursor: pointer; }
.ava-edit::after { content: '✎'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); border-radius: 50%; font-size: 13px; color: #fff; opacity: 0; transition: opacity .12s; }
.ava-edit:hover::after { opacity: 1; }
.hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.row-check { flex-direction: row !important; align-items: center; gap: 9px !important; }

.profile-panel { display: flex; gap: 24px; align-items: flex-start; max-width: 560px; }
.profile-info { flex: 1; }
.pi-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.pi-row span { color: var(--muted); }
.profile-upload { margin-top: 16px; }
.upload-label { display: inline-block; }

/* Кастомный селектор байера (с аватарками) */
.bsel { position: relative; }
.bsel-btn { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 7px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; min-width: 130px; }
.bsel-btn .chev { margin-left: auto; color: var(--muted); }
.bsel-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 44px rgba(0,0,0,.5); min-width: 230px; max-height: 380px; overflow: auto; z-index: 60; padding: 6px; }
.bsel.open .bsel-menu { display: block; }
.bsel-menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
.bsel-menu a:hover { background: var(--panel2); text-decoration: none; }
.bsel-menu a.active { background: var(--panel2); font-weight: 600; }

/* Выпадающий выбор периода (кнопка + панель справа) */
.drange { position: relative; }
.drange-btn { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 8px 13px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.drange-btn:hover { border-color: var(--muted); }
.drange-btn .dr-ic { display: inline-flex; width: 16px; height: 16px; color: var(--muted); }
.drange-btn .dr-ic svg { width: 16px; height: 16px; }
.drange-btn .chev { display: inline-flex; margin-left: 2px; color: var(--muted); }
.drange-panel { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 44px rgba(0,0,0,.5); z-index: 60; padding: 12px; width: 300px; }
.drange.open .drange-panel { display: block; }
.drange-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.drange-presets .preset { text-align: center; }
.drange-dates { display: flex; gap: 10px; }
.drange-dates label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
.drange-dates input[type=date] { width: 100%; }

/* Детальные тех-косты (Свод команды) */
.fin-block { margin-top: 30px; }
.fin-title { font-size: 17px; margin: 0 0 14px; }
.fin-team { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; background: var(--panel); }
.fin-team-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--panel2); font-size: 15px; }
.fin-team-head .sum, .fin-buyer-head .sum { margin-left: auto; font-weight: 700; }
.fin-team-head .dr-ic, .fin-buyer-head .dr-ic { display: inline-flex; width: 16px; height: 16px; color: var(--muted); }
.fin-team-head .dr-ic svg, .fin-buyer-head .dr-ic svg { width: 16px; height: 16px; }
.fin-buyer { padding: 4px 16px 14px; }
.fin-buyer-head { display: flex; align-items: center; gap: 8px; padding: 12px 0 6px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.fin-buyer:first-of-type .fin-buyer-head { border-top: 0; }
.fin-buyer-head b { color: var(--text); }
.fin-items { width: 100%; border-collapse: collapse; }
.fin-items td { padding: 7px 8px; border-top: 1px solid var(--line); font-size: 13px; }
.fin-items td.dt { color: var(--muted); white-space: nowrap; width: 110px; }
.fin-items td.r { text-align: right; white-space: nowrap; }
.fin-items thead th { padding: 7px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; }
.fin-items thead th.r { text-align: right; }

/* Карточки по байерам */
.bcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.bcard { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 16px; overflow: hidden; min-width: 0; }
.bcard-head { display: flex; align-items: center; gap: 12px; }
.bcard-who { display: flex; flex-direction: column; line-height: 1.25; }
.bcard-who b { font-size: 16px; }
.bcard-who span { color: var(--muted); font-size: 13px; }
.bcard-dep { margin-left: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.bcard-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.bcard-kpis .kpi { background: var(--panel2); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.bcard-kpis .kpi span { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.bcard-kpis .kpi b { font-size: 15px; }
.bcard-kpis .kpi b.pos { color: #34d399; } .bcard-kpis .kpi b.neg { color: #f87171; }
.bcard-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0 8px; }
.geo-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.geo-tile { display: inline-flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; color: var(--text); font-size: 14px; }
.geo-tile:hover { border-color: var(--muted); }
.geo-tile.active { border-color: #6ea8fe; background: rgba(110,168,254,.12); }
.geo-tile .gt-sub { color: var(--muted); font-size: 12px; }
.geo-offers { margin-top: 10px; border-top: 1px solid var(--line); overflow-x: auto; }
.geo-offers.hidden { display: none; }
.geo-offers .fin-items { width: 100%; table-layout: fixed; }
.geo-offers .fin-items th:first-child, .geo-offers .fin-items td:first-child { white-space: normal; word-break: break-word; }
.geo-offers .fin-items th.r, .geo-offers .fin-items td.r { width: 62px; }
.geo-offers .fin-items th:last-child, .geo-offers .fin-items td:last-child { width: 84px; }

/* Таблица сверки по партнёрам */
.fin-items.partners td.geo { white-space: nowrap; }
.fin-items.partners td.geo b { margin-left: 6px; vertical-align: middle; }
.fin-items.partners td.geo img { vertical-align: middle; }
.fin-items.partners td:nth-child(2) { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-items.partners th.r, .fin-items.partners td.r { width: 90px; white-space: nowrap; }

@media (max-width: 700px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
