:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #d0d9e6;
  --teal: #0f766e;
  --teal-dark: #0b4f49;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: "Segoe UI", Tahoma, sans-serif; }
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(15, 118, 110, 0.10) 0, rgba(15, 118, 110, 0.00) 35%),
    radial-gradient(circle at 90% 80%, rgba(2, 132, 199, 0.09) 0, rgba(2, 132, 199, 0.00) 45%),
    var(--bg);
}
.topbar {
  background: linear-gradient(120deg, var(--teal), #1f2937);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.title { font-size: 18px; font-weight: 700; }
.stats { font-size: 13px; opacity: 0.95; }
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filters select, .filters input {
  border: 1px solid rgba(255,255,255,0.42);
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 140px;
}
.filters select option { color: #0f172a; }
.filters input::placeholder { color: rgba(255,255,255,0.85); }
.top-btn {
  border: 1px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.top-btn:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.65);
}
.top-btn:active {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(255,255,255,0.85);
}
.top-btn.active {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(255,255,255,0.9);
  color: #fff;
}
.top-btn.active:hover {
  background: rgba(15, 23, 42, 0.85);
}
.top-btn.warn {
  background: rgba(220, 38, 38, 0.35);
  border-color: rgba(255,255,255,0.5);
}
.top-btn.warn:hover {
  background: rgba(220, 38, 38, 0.5);
  border-color: rgba(255,255,255,0.7);
}
.top-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-height: 0;
  padding: 12px;
}
@media (min-width: 980px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr) 420px; }
  .layout.filters-collapsed { grid-template-columns: minmax(0, 1fr) 420px; }
}
.filters-drawer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: auto;
  min-height: 420px;
  max-height: calc(100vh - 96px);
  padding: 12px;
}
.filters-drawer.hidden { display: none; }
.filters-head {
  position: relative;
  font-size: 14px;
  font-weight: 800;
  color: var(--teal-dark);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filters-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--teal-dark);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.filters-close:hover { color: var(--teal); }
.filter-row {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
}
.filter-row label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.filter-row input[type="range"] { width: 100%; }
.filter-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
.filter-row .meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.filter-row.checkbox label {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
  font-size: 13px;
  margin: 0;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.filter-reset {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
  color: var(--teal-dark);
  transition: all 0.2s ease;
}
.filter-reset:hover {
  background: #f0fffe;
  border-color: var(--teal);
}
.filter-reset:active {
  background: #e3f8f5;
  color: var(--teal);
}
.filter-reset:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@media (max-width: 979px) {
  .layout { grid-template-columns: 1fr; }
  .filters-drawer {
    position: fixed;
    top: 76px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 2500;
    overflow: auto;
    min-height: auto;
    max-height: calc(100vh - 88px);
  }
  .filters-close { display: inline-flex; }
}
.map-wrap {
  position: relative;
  min-height: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
#map { width: 100%; height: 100%; min-height: 420px; }
.legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 600;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  box-shadow: 0 6px 14px rgba(15,23,42,0.18);
  min-width: 220px;
}
.legend-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.legend-tab {
  flex: 1;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.legend-tab:hover {
  background: #f0fffe;
  border-color: rgba(15, 118, 110, 0.3);
}
.legend-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.legend-pane.hidden { display: none; }
.legend-btn {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--teal-dark);
  transition: all 0.2s ease;
}
.legend-btn:hover {
  background: #f0fffe;
  border-color: var(--teal);
}
.legend-btn.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.legend-btn.warn {
  border-color: rgba(220, 38, 38, 0.4);
  color: #b91c1c;
}
.legend-btn.warn:hover {
  background: rgba(220, 38, 38, 0.08);
}
.legend-btn.warn.active {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.vis-filter-row { margin-bottom: 8px; }
.vis-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.vis-toggle-btn {
  flex: 1;
  border: none;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.vis-toggle-btn:not(:first-child) { border-left: 1px solid var(--line); }
.vis-toggle-btn:hover { background: #f0fffe; }
.vis-toggle-btn.active {
  background: var(--teal);
  color: #fff;
}
.legend-title { font-weight: 700; margin-bottom: 6px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  color: var(--muted);
}
.legend-filter {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 4px 6px;
  transition: all 0.2s ease;
  color: var(--muted);
}
.legend-filter:hover {
  background: #f0fffe;
  border-color: rgba(15, 118, 110, 0.3);
}
.legend-filter:active { background: #e3f8f5; }
.legend-filter.active {
  border-color: var(--teal);
  background: #ecfeff;
  color: #0f172a;
  font-weight: 700;
}
.legend-filter:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.sw { width: 12px; height: 12px; border-radius: 999px; border: 1px solid #111827; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: auto;
  min-height: 420px;
  max-height: calc(100vh - 96px);
}
.panel-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(120deg, #ecfeff, #f8fafc);
  border-bottom: 1px solid var(--line);
  padding: 14px;
}
.panel-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-title { margin: 0; font-size: 18px; }
.panel-title a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed #94a3b8;
}
.panel-title a:hover {
  color: var(--teal-dark);
  border-bottom-color: var(--teal-dark);
}
.panel-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.panel-body { padding: 12px 14px 18px; }
.panel-close {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--teal-dark);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  line-height: 24px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: none;
  transition: all 0.2s ease;
}
.panel-close:hover { background: #f0fffe; border-color: var(--teal); }
.panel-close:active { background: #e3f8f5; color: var(--teal); }
.panel-close.show { display: inline-block; }
.panel-close:disabled { opacity: 0.5; cursor: not-allowed; }
.panel-actions { display: flex; gap: 6px; align-items: center; }
.panel-hide,
.panel-favourite {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--teal-dark);
  border-radius: 8px;
  min-width: 40px;
  height: 32px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: none;
  padding: 0;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.panel-hide.show,
.panel-favourite.show { display: inline-flex; }
.panel-hide:hover,
.panel-favourite:hover { background: #f0fffe; border-color: var(--teal); }
.panel-hide:active { background: #e3f8f5; color: var(--teal); }
.panel-favourite:hover { background: #fef2f2; border-color: #dc2626; }
.panel-favourite:hover svg { stroke: #dc2626; }
.panel-favourite:active { background: #fee2e2; color: #dc2626; }
.panel-favourite:active svg { stroke: #dc2626; }
.panel-favourite svg,
.panel-hide svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.panel-hide:disabled,
.panel-favourite:disabled { opacity: 0.5; cursor: not-allowed; }
.notes-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
}
.notes-wrap label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.notes-wrap textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
}
.notes-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}
.section { margin-top: 14px; }
.section h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--teal-dark); }
.detail-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.detail-tabs-head { margin-top: 10px; margin-bottom: 0; flex-wrap: wrap; }
.detail-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.detail-tab:hover:not(.active) { background: #f0fffe; border-color: var(--teal); }
.detail-tab:active:not(.active) { background: #e3f8f5; }
.detail-tab.active {
  background: #dff7f3;
  border-color: var(--teal);
  color: var(--teal-dark);
}
.detail-tab:disabled { opacity: 0.5; cursor: not-allowed; }
.detail-pane.hidden { display: none; }
.accordion {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}
.accordion > summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-dark);
  padding: 10px 12px;
  border-bottom: 1px solid transparent;
  background: #f7fbfb;
}
.accordion[open] > summary { border-bottom-color: var(--line); }
.accordion-content { padding: 4px 6px 6px; }
.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  row-gap: 2px;
}
.kv > div:not(.row) {
  grid-column: 1 / -1;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.row {
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 4px 6px;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.row:nth-child(4n+1), .row:nth-child(4n+2) { background: #fbfdff; }
.row strong {
  color: var(--ink);
  display: inline-block;
  min-width: 3ch;
  margin-bottom: 0;
  font-weight: 700;
  margin-right: 4px;
}
.row-label {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
}
.row-wide {
  grid-column: 1 / -1;
}
.row-wide textarea {
  width: 100%;
  min-height: 80px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  resize: vertical;
}
.row-checkbox {
  flex-direction: row;
  align-items: center;
}
.row-checkbox label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink);
}
.row select,
.row input[type="number"],
.row input[type="text"] {
  margin-top: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}
.desc {
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 13px;
  color: #1e293b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}
.files { list-style: none; margin: 0; padding: 0; }
.files li { margin: 6px 0; }
.files a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.planimetria-open {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-dark);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
  width: 100%;
}
.files small { color: var(--muted); }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 1200px) { .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.photo-thumb {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}
.photo-thumb:hover { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1); }
.photo-thumb:active { border-color: var(--teal-dark); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2); }
.photo-thumb img { display: block; width: 100%; height: 110px; object-fit: cover; }
.photo-lightbox,
.doc-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 20px;
}
.photo-lightbox.open,
.doc-lightbox.open { display: flex; }
.photo-stage,
.doc-stage {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
}
.doc-stage {
  width: min(95vw, 1200px);
  height: min(90vh, 900px);
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0,0,0,0.45);
}
.photo-stage img,
.doc-image {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.45);
}
.doc-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.doc-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111827;
  display: none;
}
.empty { color: var(--muted); font-size: 13px; padding: 16px 0; }
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.auction-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.auction-card:hover {
  transform: translateY(-1px);
  border-color: #8ec5bf;
  box-shadow: 0 8px 18px rgba(15,23,42,0.10);
}
.card-title {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--ink);
  font-weight: 700;
}
.card-line {
  margin: 3px 0;
  font-size: 12px;
  color: var(--muted);
}
.card-line strong { color: var(--ink); font-weight: 700; }
.marker-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #111827;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.78);
}
.marker-dot.selected {
  animation: heartbeat 950ms ease-in-out infinite;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.80),
    0 0 14px 2px rgba(250, 204, 21, 0.75),
    0 0 28px 8px rgba(250, 204, 21, 0.30);
  border-color: #facc15 !important;
}
@keyframes heartbeat {
  0% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1.02); }
  45% { transform: scale(1.22); }
  60% { transform: scale(1.0); }
  100% { transform: scale(1); }
}
