:root {
  color-scheme: light;
  --mj-canvas: #f5f7f6;
  --mj-surface: #ffffff;
  --mj-surface-raised: #fbfcfb;
  --mj-surface-muted: #edf2f0;
  --mj-ink: #17211f;
  --mj-ink-soft: #34423e;
  --mj-muted: #687671;
  --mj-line: #d9e2df;
  --mj-line-strong: #b9c8c3;
  --mj-teal: #0d766f;
  --mj-teal-strong: #075f59;
  --mj-blue: #244e76;
  --mj-amber: #b7791f;
  --mj-coral: #b4432f;
  --mj-green: #0f6b4a;
  --mj-red: #9f321f;
  --mj-focus: rgba(13, 118, 111, 0.18);
  --mj-shadow-sm: 0 1px 2px rgba(23, 33, 31, 0.07);
  --mj-shadow-md: 0 12px 30px rgba(23, 33, 31, 0.12);
  --mj-radius-sm: 6px;
  --mj-radius-md: 8px;
  --mj-radius-lg: 10px;
  --mj-space-1: 4px;
  --mj-space-2: 8px;
  --mj-space-3: 12px;
  --mj-space-4: 16px;
  --mj-space-5: 20px;
  --mj-price-low: #0f6b4a;
  --mj-price-mid: #b7791f;
  --mj-price-high: #b4432f;
  --bg: var(--mj-canvas);
  --panel: var(--mj-surface);
  --panel-2: var(--mj-surface-muted);
  --ink: var(--mj-ink);
  --muted: var(--mj-muted);
  --line: var(--mj-line);
  --accent: var(--mj-teal);
  --accent-2: var(--mj-coral);
  --shadow: var(--mj-shadow-sm);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.itbi-mode {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-height: 0;
}

.app-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: auto 1fr;
  min-height: 58px;
  padding: 9px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.mark {
  align-items: center;
  aspect-ratio: 1;
  background: var(--mj-teal-strong);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--mj-radius-sm);
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.12);
  color: #fff;
  display: flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
  width: 34px;
}

.brand-title {
  font-size: 17px;
  font-weight: 780;
  line-height: 1.05;
}

.brand-subtitle,
.status,
.topbar p {
  color: var(--muted);
  font-size: 13px;
}

.brand-badge {
  background: #eef4f2;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--mj-teal-strong);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.04em;
  padding: 4px 7px;
  text-transform: uppercase;
}

.nav {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.nav-link {
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--mj-ink-soft);
  font-size: 14px;
  font-weight: 760;
  padding: 8px 12px;
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover {
  background: #e8f3f1;
  border-color: rgba(13, 118, 111, 0.22);
  color: var(--mj-teal-strong);
}

.filter-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-lg);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  padding: 14px;
}

.filter-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
}

.filter-grid button {
  align-self: end;
}

label {
  color: var(--mj-ink-soft);
  display: grid;
  font-size: 12px;
  font-weight: 650;
  gap: 6px;
}

input,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-sm);
  color: var(--ink);
  min-height: 38px;
  outline: none;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--mj-focus);
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.grid-2 {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.button-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-top: 4px;
}

button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-sm);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 9px 12px;
}

button.primary {
  background: var(--mj-teal-strong);
  border-color: var(--mj-teal-strong);
  color: #fff;
}

button:hover {
  border-color: var(--mj-line-strong);
  filter: brightness(0.99);
}

.status {
  background: var(--mj-surface-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 34px;
  padding: 8px 10px;
}

.main {
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 18px;
}

body.itbi-mode .main {
  overflow: hidden;
}

.view {
  display: none;
  gap: 18px;
  min-height: 0;
}

.view.active {
  display: grid;
}

#itbi-view.active,
#itbi-parcels-view.active {
  height: 100%;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 820;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  font-weight: 780;
}

.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  background: var(--mj-surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-md);
  box-shadow: var(--shadow);
  min-height: 92px;
  padding: 14px;
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.metric-value {
  font-size: 23px;
  font-weight: 850;
  margin-top: 8px;
}

.metric-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.itbi-workspace {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(420px, 1fr) minmax(500px, 560px);
  height: 100%;
  min-height: 0;
}

.itbi-side {
  align-content: start;
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.itbi-search-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.itbi-search-grid .wide,
.itbi-actions {
  grid-column: 1 / -1;
}

.itbi-use-toggles {
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
  margin: 0;
  padding: 0;
}

.itbi-use-toggles label {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-sm);
  color: var(--ink);
  display: flex;
  font-size: 12px;
  gap: 6px;
  font-weight: 650;
  line-height: 1;
  min-height: 26px;
  padding: 5px 8px;
  width: auto;
}

.itbi-use-toggles input {
  accent-color: var(--accent);
  flex: 0 0 auto;
  height: 14px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 14px;
}

.address-query input {
  font-size: 15px;
  min-height: 40px;
}

.address-query {
  position: relative;
}

.address-suggestions {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-md);
  box-shadow: var(--mj-shadow-md);
  left: 0;
  overflow: hidden;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 500;
}

.address-suggestion {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.address-suggestion:last-child {
  border-bottom: 0;
}

.address-suggestion:hover,
.address-suggestion:focus-visible {
  background: #edf7f5;
  outline: none;
}

.address-suggestion strong {
  font-size: 13px;
}

.address-suggestion span {
  color: var(--muted);
  font-size: 11px;
}

.advanced-field {
  opacity: 0.78;
}

.itbi-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.hidden-field {
  display: none;
}

.map-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-lg);
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
}

.map-panel {
  min-height: 0;
}

.itbi-map-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  position: relative;
}

#map,
#parcel-map {
  height: 100%;
  min-height: 0;
  width: 100%;
}

.parcel-heat-canvas {
  opacity: 0.68;
  pointer-events: none;
}

.map-loading {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--mj-shadow-sm);
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 780;
  gap: 8px;
  left: 14px;
  min-height: 34px;
  padding: 7px 11px;
  pointer-events: none;
  position: absolute;
  top: 58px;
  z-index: 600;
}

.map-loading[hidden] {
  display: none;
}

.map-loading-spinner {
  animation: map-loading-spin 0.8s linear infinite;
  border: 2px solid rgba(13, 118, 111, 0.22);
  border-top-color: var(--accent);
  border-radius: 999px;
  height: 14px;
  width: 14px;
}

@keyframes map-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.selected-row {
  background: #eaf6f3;
}

.partial-row {
  background: #fff7e8;
}

.transaction-section-row td {
  background: #eef3f1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.transaction-section-row strong {
  color: var(--ink);
  float: right;
  letter-spacing: 0;
}

.map-legend {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-md);
  box-shadow: var(--shadow);
  color: var(--ink);
  display: grid;
  font-size: 11px;
  gap: 5px;
  padding: 9px 10px;
}

.map-legend-title {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 2px;
}

.map-legend-row {
  align-items: center;
  display: flex;
  gap: 7px;
  white-space: nowrap;
}

.map-legend-row span {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.map-popup {
  display: grid;
  font-size: 12px;
  gap: 3px;
  min-width: 160px;
}

.panel-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 14px;
}

#dossier-status,
#listing-count,
#map-status,
#row-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.itbi-table-wrap {
  max-height: none;
}

.itbi-metrics {
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.itbi-metrics .metric {
  min-height: 72px;
  padding: 11px;
}

.itbi-metrics .metric-value {
  font-size: 18px;
  margin-top: 5px;
}

.itbi-metrics .metric-note {
  font-size: 11px;
}

.itbi-search {
  gap: 10px;
  padding: 10px;
}

.itbi-transactions-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.listings-panel {
  min-height: 420px;
}

.listing-table-wrap {
  max-height: 520px;
}

#listings td:nth-child(3) {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#listings td:nth-child(5),
#listings td:nth-child(6),
#listings td:nth-child(7),
#listings td:nth-child(8) {
  text-align: right;
}

.listing-thumb {
  aspect-ratio: 4 / 3;
  background: #eef3f1;
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-sm);
  display: block;
  height: 56px;
  object-fit: cover;
  width: 74px;
}

.listing-thumb.placeholder::after {
  color: var(--muted);
  content: "sem foto";
  display: grid;
  font-size: 10px;
  height: 100%;
  place-items: center;
  text-transform: uppercase;
}

.row-action {
  min-height: 30px;
  padding: 4px 8px;
}

.price-event {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 7px;
}

.price-event.drop {
  background: #e5f4ee;
  color: var(--mj-green);
}

.price-event.up {
  background: #faebe7;
  color: var(--mj-red);
}

.price-event.neutral {
  background: #eef3f1;
  color: var(--muted);
}

.quality-badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 7px;
}

.quality-badge.clean {
  background: #e7f4ef;
  color: var(--mj-green);
}

.quality-badge.warning {
  background: #fff3d8;
  color: #8a580d;
}

.quality-badge.issue {
  background: #faebe7;
  color: var(--mj-red);
}

.quality-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dossier-panel {
  min-height: 280px;
}

.lab-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 260px) minmax(420px, 1fr) minmax(300px, 360px);
  min-height: calc(100vh - 184px);
}

.explore-search-shell {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(360px, 1fr) auto;
  margin-bottom: 14px;
}

.explore-search-box {
  align-items: center;
  background: #fff;
  border: 1px solid var(--mj-line-strong);
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(23, 33, 31, 0.08);
  display: grid;
  gap: 12px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  min-height: 58px;
  padding: 4px 5px 4px 22px;
}

.explore-search-icon {
  border: 3px solid var(--muted);
  border-radius: 999px;
  display: block;
  height: 20px;
  opacity: 0.82;
  position: relative;
  width: 20px;
}

.explore-search-icon::after {
  background: var(--muted);
  border-radius: 999px;
  bottom: -5px;
  content: "";
  display: block;
  height: 9px;
  position: absolute;
  right: -5px;
  transform: rotate(-45deg);
  width: 3px;
}

.explore-search-box input {
  border: 0;
  color: var(--ink);
  font-size: 21px;
  min-height: 42px;
  padding: 0;
}

.explore-search-box input:focus {
  box-shadow: none;
}

.explore-search-box input::placeholder {
  color: #6d6f76;
}

.explore-search-button {
  align-items: center;
  background: var(--mj-teal-strong);
  border: 1px solid var(--mj-teal-strong);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(13, 118, 111, 0.22);
  color: #fff;
  display: inline-flex;
  font-size: 18px;
  font-weight: 820;
  gap: 9px;
  justify-content: center;
  min-height: 48px;
  padding: 0 28px;
  white-space: nowrap;
}

.itbi-primary-search {
  min-height: 54px;
  padding-left: 18px;
}

.itbi-primary-search input {
  font-size: 16px;
}

.itbi-primary-search .explore-search-button {
  font-size: 15px;
  min-height: 44px;
  padding: 0 20px;
}

.explore-type-chips {
  align-items: center;
  display: flex;
  gap: 10px;
  overflow-x: auto;
}

.explore-type-chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--mj-ink-soft);
  font-size: 17px;
  font-weight: 760;
  min-height: 58px;
  padding: 0 28px;
  white-space: nowrap;
}

.explore-type-chip.active {
  background: #e8f3f1;
  border-color: rgba(13, 118, 111, 0.42);
  color: var(--mj-teal-strong);
  box-shadow: inset 0 0 0 1px rgba(13, 118, 111, 0.12);
}

.lab-filter-panel,
.lab-results-panel,
.lab-dossier-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-lg);
  box-shadow: var(--shadow);
  min-width: 0;
}

.lab-filter-panel {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 14px;
  position: sticky;
  top: 16px;
}

.lab-intent {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.intent-chip {
  background: var(--mj-surface-raised);
  border-color: var(--line);
  font-size: 12px;
  min-height: 34px;
  padding: 7px 8px;
}

.intent-chip.active {
  background: #e5f4ee;
  border-color: rgba(13, 118, 111, 0.45);
  color: var(--mj-green);
}

.lab-filter-group {
  display: grid;
  gap: 10px;
}

.lab-filter-group.two-cols {
  grid-template-columns: 1fr 1fr;
}

.lab-results-panel {
  display: grid;
  gap: 12px;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 14px;
}

.lab-results-head {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.lab-results-head p,
#lab-count {
  color: var(--muted);
  font-size: 13px;
}

#lab-count {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
  padding: 6px 10px;
  white-space: nowrap;
}

.listing-card-grid {
  align-content: start;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  overflow: auto;
  padding-right: 4px;
}

.listing-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-lg);
  cursor: pointer;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  min-height: 184px;
  overflow: hidden;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.listing-card:hover,
.listing-card.selected {
  border-color: rgba(13, 118, 111, 0.55);
  box-shadow: var(--mj-shadow-md);
  transform: translateY(-1px);
}

.lab-card-media {
  background: #eef3f1;
  min-height: 100%;
}

.lab-card-media img,
.lab-card-image.placeholder {
  display: block;
  height: 100%;
  min-height: 184px;
  object-fit: cover;
  width: 100%;
}

.lab-card-image.placeholder,
.lab-dossier-hero.placeholder,
.lab-empty {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-size: 11px;
  justify-items: center;
  text-transform: uppercase;
}

.lab-card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 11px;
}

.lab-card-topline,
.lab-card-location,
.lab-card-facts,
.lab-card-actions {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
}

.lab-card-topline {
  justify-content: space-between;
}

.lab-card-body h2 {
  display: -webkit-box;
  font-size: 14px;
  line-height: 1.25;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.lab-card-price {
  font-size: 21px;
  font-weight: 820;
  letter-spacing: 0;
}

.lab-card-facts {
  flex-wrap: wrap;
  font-weight: 750;
}

.lab-card-metrics {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lab-card-metrics div {
  background: var(--mj-surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-sm);
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px;
}

.lab-card-metrics strong {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lab-card-metrics span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.lab-signal {
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  padding: 3px 7px;
  white-space: nowrap;
}

.lab-signal.clean {
  background: #e5f4ee;
  color: var(--mj-green);
}

.lab-signal.drop {
  background: #e5eff8;
  color: var(--mj-blue);
}

.lab-signal.warning {
  background: #fff3d8;
  color: #8a580d;
}

.lab-signal.issue {
  background: #faebe7;
  color: var(--mj-red);
}

.lab-card-actions {
  justify-content: space-between;
  margin-top: 2px;
}

.lab-card-actions button {
  min-height: 30px;
  padding: 4px 8px;
}

.lab-card-actions a,
.lab-source-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.lab-dossier-panel {
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow: auto;
  position: sticky;
  top: 16px;
}

.lab-dossier {
  display: grid;
}

.lab-dossier-hero {
  background: #eef3f1;
  border-bottom: 1px solid var(--line);
}

.lab-dossier-hero img {
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  width: 100%;
}

.lab-dossier-content {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.lab-dossier-content h3 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
}

.lab-dossier-content p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.lab-decision-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.lab-gallery-strip {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lab-gallery-strip img {
  aspect-ratio: 4 / 3;
  background: #eef3f1;
  border-radius: 6px;
  object-fit: cover;
  width: 100%;
}

.lab-empty {
  background: var(--mj-surface-raised);
  border: 1px dashed var(--line);
  border-radius: var(--mj-radius-md);
  min-height: 180px;
  padding: 18px;
  text-align: center;
  text-transform: none;
}

.dossier-empty {
  color: var(--muted);
  padding: 16px;
}

.dossier {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.dossier-title {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.dossier-title h3 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
}

.dossier-title a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.dossier-gallery {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}

.dossier-gallery a {
  border-radius: 6px;
  display: block;
  overflow: hidden;
}

.dossier-gallery img {
  aspect-ratio: 4 / 3;
  background: #eef3f1;
  display: block;
  object-fit: cover;
  width: 100%;
}

.dossier-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.mini-metric {
  background: var(--mj-surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--mj-radius-sm);
  padding: 10px;
}

.mini-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mini-value {
  font-size: 15px;
  font-weight: 800;
  margin-top: 4px;
}

.event-list {
  display: grid;
  gap: 6px;
}

.event-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 140px 150px 1fr;
  padding: 8px 0 0;
}

.event-type {
  font-weight: 800;
}

.event-date,
.event-values {
  color: var(--muted);
  font-size: 12px;
}

table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: var(--mj-surface-raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  z-index: 1;
}

tbody tr:hover td {
  background: rgba(237, 247, 245, 0.64);
}

td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6),
td:nth-child(7) {
  text-align: right;
}

.itbi-transactions-panel td:nth-child(5) {
  text-align: left;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

@media (max-width: 980px) {
  .app-header,
  .itbi-workspace,
  .explore-search-shell,
  .lab-layout {
    grid-template-columns: 1fr;
  }

  .lab-filter-panel,
  .lab-dossier-panel {
    max-height: none;
    position: static;
  }

  .listing-card-grid {
    overflow: visible;
  }

  .app-header {
    grid-template-columns: 1fr;
  }

  .nav {
    justify-content: start;
  }

  .explore-type-chips {
    padding-bottom: 2px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dossier-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #map,
  #parcel-map {
    min-height: 360px;
  }

  .map-panel {
    min-height: 360px;
  }

  body {
    overflow: auto;
  }

  body.itbi-mode,
  body.itbi-mode .main {
    overflow: auto;
  }

  .shell,
  .main,
  #itbi-view.active,
  #itbi-parcels-view.active,
  .itbi-workspace,
  .itbi-side {
    height: auto;
    overflow: visible;
  }

  .shell {
    min-height: 100vh;
  }

  .itbi-transactions-panel {
    overflow: visible;
  }

  .itbi-table-wrap {
    max-height: none;
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .main,
  .app-header {
    padding: 14px;
  }

  .brand-subtitle,
  .status {
    font-size: 12px;
  }

  .nav {
    overflow-x: auto;
  }

  .grid-2,
  .dossier-grid,
  .button-row,
  .filter-grid,
  .metrics,
  .itbi-search-grid,
  .itbi-actions,
  .lab-filter-group.two-cols {
    grid-template-columns: 1fr;
  }

  .explore-search-box {
    gap: 9px;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    min-height: 52px;
    padding-left: 16px;
  }

  .explore-search-box input {
    font-size: 15px;
  }

  .explore-search-button {
    font-size: 0;
    min-height: 42px;
    padding: 0 16px;
  }

  .explore-search-button span {
    font-size: 18px;
  }

  .explore-type-chip {
    font-size: 14px;
    min-height: 44px;
    padding: 0 18px;
  }

  .event-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 20px;
  }

  #map,
  #parcel-map,
  .map-panel {
    min-height: 280px;
  }

  #map,
  #parcel-map {
    height: 45vh;
  }
}
