:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --line: #dbe3df;
  --line-strong: #bdcbc5;
  --text: #111917;
  --muted: #61706a;
  --teal: #0f766e;
  --teal-dark: #0b5e58;
  --amber: #b7791f;
  --red: #b42318;
  --green: #18794e;
  --shadow: 0 18px 45px rgba(20, 39, 34, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  border-color: var(--teal);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

input[type="file"] {
  min-height: auto;
  padding: 10px;
}

textarea {
  resize: vertical;
}

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

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

.brand-row h1 {
  margin: 0;
  font-size: 24px;
}

.brand-row p {
  margin: 2px 0 0;
  color: var(--muted);
}

.brand-row.compact {
  font-size: 17px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), transparent 38%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.login-form button,
.data-form button[type="submit"],
#newPropertyButton,
#generatePostButton {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.language-toggle {
  min-height: 34px;
  padding: 6px 10px;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.login-panel > .language-toggle {
  width: auto;
  margin-top: 18px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #101817;
  color: #eef6f3;
}

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

.nav-item {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #c4d4ce;
  text-align: left;
  padding: 10px 12px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.sidebar-foot a,
.sidebar-foot button {
  color: #dce8e4;
}

.sidebar-foot button:not(.language-toggle) {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #eef6f3;
}

.sidebar-foot .language-toggle {
  color: #101817;
}

.sidebar-foot a {
  text-decoration: none;
  font-size: 14px;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto auto auto;
  gap: 10px;
  align-items: center;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.metric-strip article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.metric-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.view-grid.single-column {
  grid-template-columns: minmax(0, 1fr);
}

.property-list-view {
  display: grid;
  gap: 16px;
}

.main-panel,
.detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.main-panel {
  overflow: hidden;
}

.detail-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-panel .panel-head,
.modal .panel-head {
  padding: 0 0 14px;
}

.panel-head h2,
.detail-panel h2 {
  margin: 0;
  font-size: 16px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td:first-child strong {
  white-space: nowrap;
}

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: -10px 0 18px rgba(20, 39, 34, 0.06);
}

tr:hover,
tr.selected {
  background: var(--surface-2);
}

tr:hover td:last-child,
tr.selected td:last-child {
  background: var(--surface-2);
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.property-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.thumb {
  width: 52px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf4f2;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.pending_review {
  background: #fff5df;
  color: var(--amber);
}

.status.draft,
.status.unlisted {
  background: #eef1f0;
  color: var(--muted);
}

.status.rented,
.status.sold {
  background: #eef8f3;
  color: var(--green);
}

.detail-hero {
  display: grid;
  gap: 12px;
}

.detail-hero img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.media-preview-grid,
.property-video-grid {
  display: grid;
  gap: 10px;
}

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

.media-preview-grid img,
.media-preview-grid video,
.property-video-grid video {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
}

.media-preview-grid img,
.media-preview-grid video {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.detail-title {
  margin: 0;
  font-size: 20px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}

.detail-meta span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.detail-actions button,
.detail-actions a {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 230px;
}

.compact-actions {
  min-width: 80px;
}

.row-actions button {
  min-height: 32px;
  padding: 5px 10px;
  white-space: nowrap;
}

.row-actions button[data-view-property],
.row-actions button[data-edit-property],
.detail-actions button[data-edit-property] {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.quick-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 112px;
  font-size: 11px;
}

.quick-status span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.quick-status select {
  width: 112px;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 750;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.pagination-controls strong {
  color: var(--text);
  font-size: 13px;
}

.users-table {
  min-width: 820px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf4f2;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.stack-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.list-item {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.list-item strong {
  font-size: 15px;
}

.list-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.list-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.list-actions button {
  min-width: 92px;
  min-height: 34px;
  padding: 5px 10px;
  border-color: var(--teal);
  color: var(--teal-dark);
}

.telegram-copy {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
  color: #26322f;
  font-size: 13px;
}

.data-form {
  display: grid;
  gap: 12px;
}

.form-section-title {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.permission-matrix {
  display: grid;
  gap: 10px;
}

.permission-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.permission-group h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.permission-group > div {
  display: grid;
  gap: 6px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

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

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.detail-modal {
  width: min(860px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(6, 17, 14, 0.45);
}

.site-body {
  background: var(--bg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(16px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.site-brand,
.site-header a {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.site-header nav a {
  color: var(--muted);
  font-size: 14px;
}

.site-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 460px);
  gap: 28px;
  align-items: end;
  padding: 44px clamp(16px, 5vw, 64px) 24px;
}

.site-hero > * {
  min-width: 0;
}

.site-hero h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
  overflow-wrap: normal;
}

.site-hero p {
  max-width: 580px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.site-filter {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 16px clamp(16px, 5vw, 64px) 56px;
}

.property-card {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.property-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}

.property-card-body {
  display: grid;
  gap: 9px;
  padding: 15px;
}

.property-card h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.property-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.price {
  color: var(--teal-dark);
  font-size: 18px;
  font-weight: 850;
}

.property-page {
  padding: 16px clamp(16px, 5vw, 64px) 56px;
}

.property-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.property-main,
.contact-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.property-main img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}

.property-video-grid {
  margin: 16px 0;
}

.property-video-grid:empty {
  display: none;
}

.property-video-grid video {
  aspect-ratio: 16 / 9;
}

.property-content {
  padding: 20px;
}

.property-content h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.contact-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.contact-panel a {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .view-grid,
  .site-hero,
  .property-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

  .sidebar {
    gap: 14px;
    padding: 14px;
  }

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

  .nav-item {
    text-align: center;
  }

  .sidebar-foot {
    grid-template-columns: 1fr 1fr;
  }

  .sidebar-foot a {
    align-self: center;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .property-grid,
  .media-preview-grid,
  .form-grid,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric-strip article {
    padding: 12px;
  }

  .metric-strip strong {
    font-size: 24px;
  }

  .row-actions,
  .pagination-bar,
  .pagination-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table,
  .users-table {
    min-width: 0;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  tr {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface);
  }

  th:last-child,
  td:last-child {
    position: static;
    box-shadow: none;
  }

  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    padding: 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
  }

  td[colspan]::before {
    content: "";
    display: none;
  }

  td:last-child {
    grid-template-columns: 1fr;
  }

  .property-cell {
    align-items: flex-start;
  }

  .thumb {
    width: 64px;
    height: 48px;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
  }

  .row-actions button {
    min-height: 40px;
  }

  .row-actions .quick-status {
    grid-column: 1 / -1;
  }

  .list-actions {
    justify-content: stretch;
  }

  .list-actions button {
    width: 100%;
    min-height: 40px;
  }

  .quick-status {
    width: 100%;
  }

  .quick-status select {
    width: 100%;
    min-height: 40px;
  }

  .site-header,
  .site-header nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-hero h1 {
    max-width: 340px;
    font-size: 30px;
    line-height: 1.08;
  }

  .site-hero p {
    max-width: 340px;
    font-size: 16px;
  }
}
