/* Дизайн в стиле Циан: светлая тема, синий акцент, скруглённые карточки */
:root {
  --blue: #0168ff;
  --blue-dark: #0053d6;
  --blue-soft: #eaf2ff;
  --ink: #1d2433;
  --muted: #6b7480;
  --line: #e4e7eb;
  --paper: #fff;
  --bg: #f5f6f8;
  --red: #e5484d;
  --green: #0fa968;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }

/* Шапка */
.topbar { height: 60px; padding: 0 max(24px, calc((100vw - 1500px)/2)); display: flex; align-items: center; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 16px; letter-spacing: .2px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; color: #fff; background: var(--blue); border-radius: 9px; font-size: 17px; font-weight: 800; }
.account { display: flex; align-items: center; gap: 12px; }
.account form { margin: 0; }
.status { color: var(--muted); font-size: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--green); }
.admin-link { color: var(--blue); font-weight: 700; text-decoration: none; }
.admin-link:hover { color: var(--blue-dark); }
.admin-button { padding: 8px 14px; color: #fff; background: var(--blue); border-radius: 8px; font-weight: 700; text-decoration: none; }
.admin-button:hover { background: var(--blue-dark); }
.logout { padding: 8px 12px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.logout:hover { color: var(--ink); border-color: #c9ced6; }

main { width: min(1500px, calc(100% - 40px)); margin: 0 auto 60px; }

/* Заголовок страницы */
.hero { display: flex; justify-content: space-between; align-items: end; padding: 30px 4px 20px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); font-weight: 800; letter-spacing: -.3px; }
.subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* Карточки-панели */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(20, 40, 80, .04); }

/* Фильтры */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 14px; padding: 18px; }
.field { min-width: 0; }
.field.wide { grid-column: span 2; }
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
input:not([type="radio"]):not([type="checkbox"]), select { width: 100%; height: 40px; padding: 0 11px; color: var(--ink); background: var(--paper); border: 1px solid #d4d9e0; border-radius: 8px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:not([type="radio"]):not([type="checkbox"]):focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(1, 104, 255, .12); }
input[type="radio"], input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.range > div { display: flex; gap: 7px; }
.filter-actions { display: flex; align-items: end; gap: 8px; }

/* Кнопки */
.primary, .secondary, .export-button { height: 40px; padding: 0 18px; border-radius: 8px; cursor: pointer; font-weight: 700; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.primary, .export-button { color: #fff; background: var(--blue); }
.primary:hover, .export-button:hover { background: var(--blue-dark); }
.secondary { color: var(--blue); background: #fff; border-color: #cfd6e0; }
.secondary:hover { background: var(--blue-soft); border-color: var(--blue); }
.export-button { height: 44px; }
.export-button span { margin-right: 8px; font-size: 17px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Таблица */
.data-panel { margin-top: 16px; overflow: hidden; }
.table-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.table-heading strong { font-size: 15px; }
.table-heading #page-label { margin-left: 12px; color: var(--muted); font-size: 12px; }
.limit-badge { padding: 5px 10px; color: var(--blue); background: var(--blue-soft); border-radius: 99px; font-size: 11px; font-weight: 700; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 1300px; border-collapse: collapse; }
th { position: sticky; top: 0; padding: 11px 13px; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; z-index: 1; }
td { padding: 12px 13px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
tbody tr:hover { background: var(--blue-soft); }
.address { min-width: 260px; max-width: 380px; }
.number { white-space: nowrap; font-variant-numeric: tabular-nums; }
.price { color: var(--blue); font-weight: 800; }
a { color: var(--blue); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
.tag { display: inline-block; padding: 3px 8px; background: #f0f2f5; border-radius: 6px; white-space: nowrap; font-size: 12px; color: var(--ink); }
.tag-blue { display: inline-block; padding: 3px 8px; background: var(--blue-soft); color: var(--blue); border-radius: 6px; white-space: nowrap; font-size: 12px; font-weight: 700; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 16px; }
.pagination button { min-width: 105px; }
.pagination div { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.message { margin: 16px; padding: 12px 14px; color: #a02c2c; background: #fff0f0; border: 1px solid #f3cfcf; border-radius: 8px; }
.hidden { display: none; }
.empty { padding: 50px; color: var(--muted); text-align: center; }
.loading { opacity: .45; }

/* Вход */
.login-page { min-height: 100vh; background: linear-gradient(160deg, #eaf2ff 0%, var(--bg) 45%, #e9edf5 100%); }
.login-shell { width: 100%; min-height: 100vh; display: grid; place-items: center; margin: 0; padding: 24px; }
.login-card { width: min(400px, 100%); padding: 36px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(15, 45, 120, .10); }
.login-brand { margin-bottom: 22px; }
.login-card h1 { font-size: 26px; }
.login-hint { margin: 10px 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 16px; }
.login-form .primary { width: 100%; margin-top: 4px; height: 44px; }
.login-error { margin: 0 0 16px; padding: 11px 13px; color: #a02c2c; background: #fff0f0; border: 1px solid #f3cfcf; border-radius: 8px; }

/* Админка */
.admin-main { padding-bottom: 60px; }
.admin-create { padding: 20px; }
.admin-create h2 { margin: 0 0 16px; font-size: 18px; font-weight: 800; }
.admin-create form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 14px; }
.security-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.users-panel { margin-top: 16px; overflow: hidden; }
.users-table { min-width: 1050px; }
.inline-form { display: flex; gap: 7px; }
.inline-form input { min-width: 180px; }
.danger { height: 40px; padding: 0 14px; color: var(--red); background: #fff; border: 1px solid #f0c4c4; border-radius: 8px; cursor: pointer; }
.danger:hover { background: #fff0f0; }
.protected { color: var(--muted); font-size: 12px; }
.success-message { margin: 0 0 18px; padding: 12px 14px; color: #0c7a4d; background: #e8f8f0; border: 1px solid #b9e8d2; border-radius: 8px; }

/* Карта */
.map-body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.map-main { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; min-width: 0; }
.map-panel { width: 380px; overflow-y: auto; border-radius: 0; border: none; border-left: 1px solid var(--line); padding: 16px; }
.map-panel h1 { font-size: 20px; }
.map-search { margin: 12px 0; }
.building-list { display: grid; gap: 10px; margin-top: 12px; }
.building-item { padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.building-item:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(1, 104, 255, .10); }
.building-item.active { border-color: var(--blue); background: var(--blue-soft); }
.building-item .bi-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.building-item .bi-dev { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.building-item .bi-stats { display: flex; gap: 14px; font-size: 12px; }
.building-item .bi-stats b { display: block; font-size: 13px; color: var(--ink); }
.building-item .bi-stats span { color: var(--muted); }
.building-item .bi-price { color: var(--blue); }
.building-card { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.building-card h2 { font-size: 16px; margin: 0 0 10px; }
.building-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0 0 14px; }
.building-card dt { color: var(--muted); font-size: 12px; }
.building-card dd { margin: 0; font-size: 14px; font-weight: 600; }
.card-link { display: inline-block; text-decoration: none; }

@media (max-width: 1100px) { .filters { grid-template-columns: repeat(3, 1fr); } .field.wide { grid-column: span 2; } }
@media (max-width: 720px) {
  main { width: min(100% - 24px, 1500px); }
  .topbar { padding: 0 16px; }
  .hero { align-items: flex-start; gap: 16px; }
  .filters { grid-template-columns: 1fr 1fr; padding: 14px; }
  .field.wide, .filter-actions { grid-column: span 2; }
  .export-button { white-space: nowrap; font-size: 0; }
  .export-button span { margin: 0; font-size: 20px; }
  .table-heading #page-label { display: block; margin: 3px 0 0; }
  .admin-create form { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .map-main { flex-direction: column; }
  .map-panel { width: auto; border-left: none; border-top: 1px solid var(--line); max-height: 45%; }
}

/* Маркер ЖК на карте (стиль через класс — CSP блокирует inline-стили) */
.pin-marker { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--blue); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 40, 120, .4); }

/* Мультиселект (выпадающий список с чекбоксами и поиском) */
.ms { position: relative; }
.ms-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 40px; height: auto; padding: 6px 11px; text-align: left; color: var(--ink); background: var(--paper); border: 1px solid #d4d9e0; border-radius: 8px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.ms-toggle:hover { border-color: var(--blue); }
.ms.open .ms-toggle { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(1, 104, 255, .12); }
.ms-toggle .ms-placeholder { color: var(--muted); }
.ms-toggle .ms-caret { flex: none; color: var(--muted); font-size: 11px; }
.ms-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ms-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; background: var(--blue-soft); color: var(--blue); border-radius: 6px; font-size: 12px; font-weight: 600; max-width: 180px; }
.ms-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chip button { display: grid; place-items: center; width: 16px; height: 16px; padding: 0; color: var(--blue); background: transparent; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; line-height: 1; }
.ms-chip button:hover { background: #d4e4ff; }
.ms-drop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; display: none; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 32px rgba(20, 40, 80, .16); overflow: hidden; }
.ms.open .ms-drop { display: flex; }
.ms-search { height: 38px; border: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.ms-search:focus { box-shadow: none; }
.ms-list { max-height: 260px; overflow-y: auto; padding: 6px; }
.ms-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.ms-item:hover { background: var(--blue-soft); }
.ms-item input { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.ms-item .ms-empty { color: var(--muted); }
.ms-actions { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); }
.ms-actions button { padding: 5px 10px; color: var(--blue); background: transparent; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 700; }
.ms-actions button:hover { background: var(--blue-soft); }

/* Кнопка ID лота и выпадающее меню (позиционирование через CSS-классы — CSP блокирует inline-стили) */
.lot-cell { position: relative; white-space: nowrap; }
.lot-id { padding: 0; color: var(--blue); background: transparent; border: none; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 700; }
.lot-id:hover { color: var(--blue-dark); text-decoration: underline; }
.lot-popover { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; display: flex; flex-direction: column; min-width: 240px; padding: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 32px rgba(20, 40, 80, .16); }
.pop-item { display: block; padding: 9px 11px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.pop-item:hover { background: var(--blue-soft); text-decoration: none; }

/* Карточка лота */
.lot-info { margin-top: 16px; padding: 20px; }
.lot-info dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 20px; margin: 0; }
.lot-info dt { color: var(--muted); font-size: 12px; }
.lot-info dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; }
.lot-chart-panel { margin-top: 16px; overflow: hidden; }
.chart-wrap { padding: 10px 14px 6px; overflow-x: auto; }
.chart { display: block; width: 100%; min-width: 640px; height: auto; }
.chart-grid { stroke: #eef1f4; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: #fff; stroke: var(--blue); stroke-width: 2.5; }
.chart-value { fill: var(--muted); font-size: 8.5px; font-weight: 600; }
.chart-tip { opacity: 0; transition: opacity .12s ease; pointer-events: none; }
circle.chart-dot:hover + .chart-tip,
circle.chart-dot-zero:hover + .chart-tip { opacity: 1; }
.chart-tip-box { fill: #fff; stroke: var(--line); stroke-width: 1; filter: drop-shadow(0 4px 10px rgba(20, 40, 80, .12)); }
.chart-tip-price { fill: var(--ink); font-size: 10px; font-weight: 800; }
.chart-tip-date { fill: var(--muted); font-size: 9px; }
.chart-note { margin: 0; padding: 10px 16px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.chart-tick { fill: var(--muted); font-size: 11px; }
.chart-label { margin-left: 12px; color: var(--muted); font-size: 12px; }
.chart-dot-zero { fill: #fff; stroke: #b6bec9; stroke-width: 2; }
.chart-period { display: flex; gap: 6px; }
.chart-period button { height: 30px; padding: 0 13px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-size: 12px; font-weight: 700; }
.chart-period button:hover { color: var(--blue); border-color: var(--blue); }
.chart-period button.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.tag-absent { margin-left: 8px; color: var(--red); background: #fff0f0; }

@media (max-width: 1100px) { .lot-info dl { grid-template-columns: repeat(2, 1fr); } }

/* Уведомления об изменении цены */
.alert-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; text-decoration: none; font-size: 16px; }
.alert-bell:hover { background: #f0f4ff; }
.alert-count { position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.hidden { display: none !important; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.unread-row { background: #f0f6ff; }
.unread-row td:first-child { border-left: 3px solid var(--blue); }
.ua-cell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.page-link { display: inline-flex; align-items: center; padding: 0 14px; height: 32px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: 600; color: var(--ink); }
.page-link:hover { border-color: var(--blue); color: var(--blue); }
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 13px; }
/* Единый размер кнопок действий в таблицах */
.table-actions button { width: 104px; }
/* Автодополнение подсказок в текстовых полях */
.suggest-wrap { position: relative; }
.suggest-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 240px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(20, 40, 80, .14); }
.suggest-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.suggest-list li:hover, .suggest-list li.active { background: #f0f4ff; color: var(--blue); }
/* Строка формы уведомлений: критерий и направление на одном уровне */
.fields-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .fields-row { grid-template-columns: 1fr; } }
/* Форма уведомлений — вертикальная, чтобы строка «критерий + направление» была во всю ширину */
.alerts-form { grid-template-columns: 1fr !important; align-items: start !important; }
