/* DataHulk — стиль «Бенто».
   Белое поле, плитки со скруглением 28px разного размера, насыщенные цвета: фиолетовый, коралловый, лайм, небесный, чёрный.
   Шрифт Manrope. Всё строится из готовых плиток: .tile (+ .violet/.coral/.lime/.sky/.ink/.soft), .bento (сетка 4 колонки),
   .kpis (ряд цветных плиток с цифрами), .card (плитка с заголовком, графиком или таблицей). Новые отчёты собираются из них. */

:root {
  --bg: #FFFFFF;
  --soft: #F3F3F1;
  --soft-2: #E9E9E6;
  --line: #E2E2DE;
  --ink: #111111;
  --ink-2: #3A3A3A;
  --muted: #6A6A6A;
  --violet: #6C4CF1;
  --coral: #FF6B57;
  --lime: #D7F75B;
  --sky: #8FD3FF;
  --rise: #E5482F;      /* подорожание — текст на белом, контраст ≥ 4.5 */
  --fall: #2E61D9;      /* подешевление */
  --ok: #1F8A4C;
  --warn: #B26B00;
  --radius: 28px;
  --radius-sm: 16px;
  --font: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar: 248px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 500 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-x: clip; }
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
button, input, select { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 10px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.num, .mono { font-variant-numeric: tabular-nums; }
.nowrap, .num { white-space: nowrap; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error-text { color: var(--rise); font-weight: 700; }

/* ---------------------------------------------------------- Каркас */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); flex: none; background: var(--ink); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 8px 8px; font-weight: 800; font-size: 21px; letter-spacing: -0.03em; }
.nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 12px; font-weight: 700; color: #9A9A9A; padding: 0 12px 4px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px; border-radius: 14px; text-decoration: none; color: #D9D9D9; font-weight: 600; transition: background .15s, color .15s; }
.nav-link .ic { color: #8C8C8C; flex: none; }
.nav-link:hover { background: #222; color: #fff; }
.nav-link.active { background: var(--lime); color: var(--ink); }
.nav-link.active .ic { color: var(--ink); }
.logout { margin-top: auto; }
.as-button { width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 22px clamp(16px, 2.6vw, 36px) 6px; }
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font-size: clamp(24px, 2.6vw, 34px); font-weight: 800; line-height: 1.1; text-wrap: balance; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.topbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar .menu-btn { display: none; }
.main { padding: 16px clamp(16px, 2.6vw, 36px) 40px; display: flex; flex-direction: column; gap: 16px; max-width: 1480px; width: 100%; }
.scrim { display: none; }

@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 0 100vmax rgba(0,0,0,0); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .topbar .menu-btn { display: inline-grid; }
}

/* ---------------------------------------------------------- Плитки */
.tile, .card, .kpi { border-radius: var(--radius); background: var(--soft); }
.tile { padding: 22px; display: flex; flex-direction: column; overflow: hidden; }
.tile.violet, .kpi:nth-child(5n+1) { background: var(--violet); color: #fff; }
.tile.coral, .kpi:nth-child(5n+2) { background: var(--coral); color: var(--ink); }
.tile.lime, .kpi:nth-child(5n+3) { background: var(--lime); color: var(--ink); }
.tile.sky, .kpi:nth-child(5n+4) { background: var(--sky); color: var(--ink); }
.tile.ink, .kpi:nth-child(5n+5) { background: var(--ink); color: #fff; }
.tile.soft { background: var(--soft); }
.tile .label { font-size: 14px; font-weight: 700; opacity: .85; }
.tile .big { font-size: clamp(40px, 4.6vw, 72px); font-weight: 800; letter-spacing: -0.045em; line-height: 1; margin-top: 6px; }
.tile .foot { font-weight: 700; margin-top: auto; padding-top: 10px; }
.bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(170px, auto); gap: 14px; }
.w2 { grid-column: span 2; } .w3 { grid-column: span 3; } .w4 { grid-column: 1 / -1; } .h2 { grid-row: span 2; }
@media (max-width: 1100px) { .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } .w3, .w4 { grid-column: 1 / -1; } }
@media (max-width: 560px) { .bento { grid-template-columns: minmax(0, 1fr); } .w2, .w3, .w4 { grid-column: auto; } .h2 { grid-row: auto; } }

/* Ряд цифр: цвета идут по кругу фиолетовый → коралловый → лайм → небесный → чёрный */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1400px) { .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi-value { font-size: 26px; } }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.kpi .kpi-icon { display: none; }
.kpi-label { font-size: 14px; font-weight: 700; opacity: .85; }
.kpi-value { font-size: 34px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.15; white-space: nowrap; }
.kpi-sub { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0; line-height: 1.2; opacity: .85; }
.kpi-foot { font-size: 13px; font-weight: 600; opacity: .9; margin-top: auto; padding-top: 6px; }
.kpi .muted, .kpi .pct { color: inherit !important; opacity: .9; }
.kpi .pct { font-weight: 800; }

/* Плитка-карточка с заголовком: графики, таблицы, списки */
.card { padding: 6px 0 10px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 16px 22px 10px; }
.card-head.compact { padding: 12px 22px 6px; }
.card-head h2 { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { display: none; }
.card > .table-wrap, .card > .chart-box, .card > .hint, .card > form, .card > .pager, .card > p, .card > .empty, .card > ul, .card > .bars, .card > .idx-desc { margin-left: 22px; margin-right: 22px; }
.card > .table-wrap { margin-left: 8px; margin-right: 8px; }
.ac-foot { padding: 6px 0 4px; }
.card.white { background: #fff; border: 2px solid var(--soft-2); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; align-items: start; }
.prices-two { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .prices-two { grid-template-columns: minmax(0, 1fr); } }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 36px 20px; color: var(--ink-2); }
.empty p { margin: 0; max-width: 620px; }
.empty .ic { color: var(--violet); }

/* Графики */
.chart-box { position: relative; height: 240px; padding: 4px 0 8px; }
.chart-box.tall { height: 340px; }
@media (max-width: 600px) { .chart-box.tall { height: 260px; } }

/* Описание методики под графиком */
.idx-desc { margin: 8px 22px 12px; padding: 14px 18px; border-radius: var(--radius-sm); background: #fff; max-width: 1100px; }
.idx-desc h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.idx-desc p { margin: 0 0 6px; color: var(--ink-2); line-height: 1.6; }
.idx-desc p:last-child { margin-bottom: 0; }
.method { padding-bottom: 12px; }
.method summary { cursor: pointer; list-style: none; }
.method summary::-webkit-details-marker { display: none; }
.method-body { padding: 0 22px 8px; color: var(--ink-2); line-height: 1.6; max-width: 1000px; }
.method-body p { margin: 0 0 10px; }

/* Кнопки, поля, чипы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .1s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #2A2A2A; }
.btn.ghost { background: #fff; border-color: var(--soft-2); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--soft); cursor: pointer; }
.icon-btn:hover { background: var(--soft-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--soft-2); background: #fff; font-weight: 700; cursor: pointer; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
input, select { min-height: 44px; padding: 0 14px; border-radius: 14px; border: 2px solid var(--soft-2); background: #fff; font-size: 16px; width: 100%; }
input:hover, select:hover { border-color: #CFCFCB; }
input:focus, select:focus { outline: none; border-color: var(--violet); }
select { cursor: pointer; }
.field.inline { min-width: 180px; }
.field.inline.narrow { min-width: 120px; flex: 0 1 150px; }
.field.grow { flex: 1 1 260px; }
.prices-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 0 0 12px; }
.toolbar-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* Таблицы */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 800; color: var(--muted); padding: 10px 14px; white-space: nowrap; }
.table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: rgba(255,255,255,.6); }
.table .num, .table td.num, .table th.num { text-align: right; }
.table.compact td, .table.compact th { padding: 8px 14px; }
.table tr.dim td { color: var(--muted); }
.table tfoot th, .table tfoot td { padding: 12px 14px; border-top: 2px solid var(--ink); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 4px; flex-wrap: wrap; }

/* Статусы и изменения */
.pct { font-weight: 800; white-space: nowrap; }
.pct.rise { color: var(--rise); }
.pct.fall { color: var(--fall); }
.pct.same { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.pill.on { background: #DDF5E6; color: var(--ok); }
.pill.warn { background: #FFF0D6; color: var(--warn); }
.pill.off { background: #FDE3DE; color: var(--rise); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sale { color: var(--ok); font-size: 12px; font-weight: 700; }
.link { color: var(--violet); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Рейтинги полосками (районы, вклад групп, корзина) */
.bars { display: flex; flex-direction: column; gap: 9px; padding: 4px 0 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr) auto auto; gap: 12px; align-items: center; font-size: 14px; font-weight: 600; }
.bar-row .track { height: 14px; border-radius: 7px; background: #fff; position: relative; overflow: hidden; }
.bar-row .track i { position: absolute; inset: 0 auto 0 0; border-radius: 7px; background: var(--violet); }
.bar-row .track.center i { inset: 0 auto; }
.bar-row .axis { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--ink); }
@media (max-width: 560px) { .bar-row { grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr) auto; } .bar-row > :nth-child(4) { display: none; } }

/* Списки «подорожали / подешевели» */
.movers-title { margin: 10px 22px 4px; font-size: 14px; font-weight: 800; }
.movers-empty { margin: 0 22px 8px; }
.movers { list-style: none; margin: 0 0 8px; padding: 0; }
.movers li { border-top: 1px solid var(--line); }
.link-row { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 22px; background: none; border: 0; color: var(--ink); font: 600 14px var(--font); text-align: left; cursor: pointer; }
.link-row:hover .mv-title { color: var(--violet); text-decoration: underline; }
.table .link-row { display: inline; width: auto; padding: 0; }
.mv-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.mv-price { color: var(--muted); font-size: 13px; white-space: nowrap; }
@media (max-width: 520px) { .mv-price { display: none; } }

/* Корзина */
.basket-table td:nth-child(3) { width: 100%; }
.basket-items { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 260px; }
.bchip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 4px 3px 12px; border-radius: 999px; background: #fff; font-size: 13px; }
.bchip .link-row { display: block; width: auto; max-width: 240px; padding: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bchip.gone { outline: 2px dashed var(--soft-2); opacity: .7; }
.bchip-x { width: 26px; height: 26px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.bchip-x:hover { background: #FDE3DE; color: var(--rise); }
.basket-strip { display: flex; height: 64px; gap: 4px; margin: 4px 22px 14px; }
.basket-strip span { display: flex; align-items: flex-end; padding: 8px; border-radius: 14px; font-size: 13px; font-weight: 800; overflow: hidden; white-space: nowrap; }

/* Диалоги */
.item-dialog { width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: var(--radius); background: #fff; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.item-dialog::backdrop { background: rgba(17,17,17,.45); }
.item-dialog .card-head { padding: 18px 22px 8px; }
.item-body { padding: 0 22px 18px; }
.item-body .chart-box { height: 240px; }
.add-list { max-height: 50vh; overflow: auto; margin-top: 8px; padding: 0; list-style: none; }
.ad-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 16px; margin: 4px 0 12px; }
.ad-facts dt { font-size: 12px; color: var(--muted); font-weight: 700; }
.ad-facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

/* Вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--soft); }
.login-card { width: min(420px, 100%); background: #fff; border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 24px; letter-spacing: -0.03em; }
.alert { padding: 12px 14px; border-radius: 14px; font-weight: 700; }
.alert.error { background: #FDE3DE; color: var(--rise); }
.form { display: flex; flex-direction: column; gap: 14px; }
.btn.block { width: 100%; min-height: 48px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Обзор: столбики индекса внутри фиолетовой плитки и столбики по комнатам */
.dash-cols { display: flex; align-items: flex-end; gap: 8px; flex: 1; min-height: 170px; margin-top: 18px; }
.dash-cols div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; font-size: 13px; font-weight: 700; }
.dash-cols i { display: block; width: 100%; min-height: 6px; border-radius: 12px 12px 4px 4px; background: #fff; }
.dash-cols div:not(:last-child) i { opacity: .55; }
.dash-rooms { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; align-items: end; height: 220px; padding: 0 22px 12px; }
.dash-rooms div { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.dash-rooms i { display: block; border-radius: 16px 16px 6px 6px; }
.dash-rooms b { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.dash-rooms span { font-weight: 800; margin-top: 6px; }
a.tile:hover, a.card:hover { filter: brightness(1.03); }
