:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #667281;
  --line: #dce3ea;
  --primary: #216869;
  --primary-strong: #174f50;
  --danger: #b42318;
  --success: #177245;
  --shadow: 0 12px 28px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0;
}

.nav {
  display: flex;
  gap: 18px;
  flex: 1;
}

.shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px;
}

.guest {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
}

.login-shell {
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.page-head,
.section-head {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  margin-bottom: 6px;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
  margin-bottom: 6px;
}

.page-head p,
.login-card p,
.empty,
small {
  color: var(--muted);
}

.button,
button {
  align-items: center;
  background: #eef3f4;
  border: 1px solid #cbd7dc;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  min-height: 40px;
  justify-content: center;
  padding: 8px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  text-decoration: none;
}

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

.button.primary:hover {
  background: var(--primary-strong);
}

.button.danger {
  background: #fff3f1;
  border-color: #ffc7bf;
  color: var(--danger);
}

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 32px;
  padding: 5px 10px;
}

.button.full {
  width: 100%;
}

.link-button {
  background: none;
  border: 0;
  color: var(--danger);
  min-height: 0;
  padding: 0;
}

.alert {
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.alert.success {
  background: #eaf7ef;
  color: var(--success);
}

.alert.danger {
  background: #fff0ee;
  color: var(--danger);
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 24px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}

.split {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  margin-bottom: 24px;
}

.stack {
  display: grid;
  gap: 12px;
}

.mini-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.mini-card span {
  color: var(--muted);
  display: block;
  font-size: 14px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.sort-link {
  color: inherit;
  display: inline-flex;
  font-weight: 800;
}

.external-link {
  font-weight: 750;
}

td small {
  display: block;
}

tr:last-child td {
  border-bottom: 0;
}

.actions,
.form-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.form {
  display: grid;
  gap: 16px;
}

.form.compact {
  box-shadow: none;
  margin-bottom: 20px;
  padding: 0;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.filters {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
  margin-bottom: 18px;
}

.badge {
  background: #edf5f5;
  border-radius: 999px;
  color: var(--primary-strong);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
}

.thumbnail-link {
  display: inline-flex;
}

.property-thumb {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: #eef3f4;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  justify-content: center;
  object-fit: cover;
  overflow: hidden;
  width: 72px;
}

.delta-good {
  color: var(--success);
  font-weight: 750;
}

.delta-bad {
  color: var(--danger);
  font-weight: 750;
}

.details {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: 150px minmax(0, 1fr);
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

.details dd {
  margin: 0;
}

.inline-form {
  align-items: center;
  display: flex;
  gap: 10px;
}

.photo-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.photo-grid figure {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  overflow: hidden;
}

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

.photo-grid figcaption {
  align-items: center;
  display: flex;
  font-size: 13px;
  gap: 8px;
  justify-content: space-between;
  padding: 10px;
}

@media (max-width: 820px) {
  .topbar,
  .page-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
    padding: 14px 18px;
    position: static;
  }

  .nav {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .page-head .button,
  .section-head .button,
  .actions,
  .form-actions,
  .inline-form {
    width: 100%;
  }

  .actions,
  .form-actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .actions .button,
  .actions form,
  .form-actions .button,
  .form-actions button,
  .inline-form .button,
  .inline-form button {
    width: 100%;
  }

  .shell {
    padding: 18px;
  }

  h1 {
    font-size: 28px;
  }

  .stats-grid,
  .split,
  .grid.two,
  .grid.three,
  .filters {
    grid-template-columns: 1fr;
  }

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

  .panel,
  .login-card {
    padding: 18px;
  }

  .details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .shell {
    padding: 14px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat strong {
    font-size: 22px;
  }

  .table-wrap {
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  table {
    border-collapse: separate;
    border-spacing: 0 12px;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  td {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 12px;
    text-align: right;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 42%;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }

  td:not([data-label]) {
    display: block;
    text-align: left;
  }

  td:not([data-label])::before {
    content: none;
  }

  .property-thumb {
    width: 96px;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }
}
