:root {
  --bg: #f3f6f4;
  --text: #1d2930;
  --muted: #6c7a80;
  --line: #d9e2df;
  --panel: #ffffff;
  --primary: #0f5f58;
  --primary-dark: #0a433e;
  --gold: #c49a52;
  --gold-soft: #f5ead7;
  --danger: #b42318;
  --shadow: 0 24px 60px rgba(31, 51, 49, .12);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(196, 154, 82, .16), transparent 34rem),
    linear-gradient(180deg, #fbfcfb 0%, var(--bg) 100%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-page {
  background:
    linear-gradient(90deg, rgba(7, 31, 34, .78) 0%, rgba(7, 31, 34, .52) 38%, rgba(7, 31, 34, .12) 100%),
    url("/static/core/real-estate-hero.228625d3ee7c.png") center / cover fixed;
}

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

a:hover {
  text-decoration: underline;
}

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

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid rgba(217, 226, 223, .8);
  backdrop-filter: blur(14px);
  padding: 12px 24px;
}

.logo {
  color: var(--text);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-image {
  display: block;
  width: 260px;
  height: auto;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #143b45);
  color: #fff;
  font-size: 14px;
  letter-spacing: .08em;
  box-shadow: 0 10px 20px rgba(15, 95, 88, .22);
}

.topnav {
  position: absolute;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.topnav form {
  margin: 0;
}

.topnav button,
.entry-actions button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto;
}

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

.auth-card {
  max-width: 460px;
  margin: 72px auto 0;
  border-color: rgba(255, 255, 255, .34);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(18px);
}

.narrow {
  max-width: 720px;
  margin: 0 auto;
}

h1,
h2,
h3 {
  margin: 0 0 16px;
  line-height: 1.2;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -.01em;
}

h2 {
  font-size: 22px;
}

.auth-kicker {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.auth-intro {
  color: var(--muted);
  margin: -4px 0 20px;
}

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

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

.form p {
  margin: 0;
  display: grid;
  gap: 6px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.form input,
.form select,
.form textarea,
.filters input,
.filters select,
.copy-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .96);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form input:focus,
.form select:focus,
.form textarea:focus,
.filters input:focus,
.filters select:focus,
.copy-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 95, 88, .12);
  outline: 0;
}

.phone-input {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.phone-input__prefix {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 6px 0 0 6px;
  background: #f7faf8;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.phone-input input {
  flex: 1;
  min-width: 0;
  border-radius: 0 6px 6px 0;
}

.phone-input input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 95, 88, .12);
  outline: 0;
}

.primary,
.as-link.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(15, 95, 88, .18);
}

.primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border-radius: 6px;
  padding: 10px 12px;
  background: #eef4ff;
  border: 1px solid #c7d7ff;
}

.dashboard {
  display: grid;
  gap: 18px;
}

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

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 8px 20px rgba(31, 51, 49, .06);
  white-space: nowrap;
}

.tabs a.active {
  background: linear-gradient(135deg, var(--primary), #163f49);
  border-color: var(--primary);
  color: #fff;
}

.page-title {
  background:
    linear-gradient(135deg, rgba(15, 95, 88, .95), rgba(24, 62, 72, .92)),
    linear-gradient(90deg, rgba(196, 154, 82, .18), transparent);
  border-radius: 8px;
  color: #fff;
  padding: 24px;
  box-shadow: var(--shadow);
}

.page-title .muted {
  color: rgba(255, 255, 255, .76);
}

.page-title .primary {
  border: 1px solid rgba(255, 255, 255, .78);
  box-shadow:
    0 0 0 0 rgba(255, 255, 255, .34),
    0 12px 28px rgba(2, 49, 45, .26);
  animation: dealButtonPulse 2.8s ease-in-out infinite;
}

.page-title .primary:hover {
  border-color: #fff;
  transform: translateY(-1px);
}

@keyframes dealButtonPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 0 rgba(255, 255, 255, .28),
      0 12px 28px rgba(2, 49, 45, .26);
  }

  50% {
    box-shadow:
      0 0 0 7px rgba(255, 255, 255, .08),
      0 16px 34px rgba(2, 49, 45, .32);
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-title .primary {
    animation: none;
  }
}

.filters {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.filters button,
.inline-upload button:not(.upload-btn),
.row-actions button,
td form button {
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions form {
  margin: 0;
}

.row-actions .danger-button,
td form .danger-button {
  border-color: var(--danger);
  color: var(--danger);
}

.danger-text {
  color: var(--danger);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  background: #f7faf8;
}

.documents-row td {
  background: #f8fbfa;
  font-size: 14px;
}

.inline-upload {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.copy-field {
  margin-bottom: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

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

.management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.management-grid .panel:first-child {
  min-width: 0;
}

.doc-list {
  margin: 0;
  padding-left: 20px;
}

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

.entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.entry h3,
.entry p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.entry-date {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #7a5620;
  padding: 4px 9px;
  font-size: 13px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f8fbfa);
}

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

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  margin-top: 4px;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.entry-actions form {
  margin: 0;
}

.entry-actions a,
.entry-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1.2;
}

.entry-actions a:hover,
.entry-actions button:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.profile-actions {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 18px;
}

.soft-separator {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

.settings-note {
  margin-top: 16px;
}

.settings-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.settings-status div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfa;
  min-width: 0;
}

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

.settings-status strong {
  display: block;
  overflow-wrap: anywhere;
}

.errorlist {
  color: var(--danger);
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: center;
    flex-direction: column;
    gap: 10px;
    min-height: auto;
    padding: 12px 14px 14px;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    text-align: center;
  }

  .logo {
    justify-content: center;
    width: 100%;
  }

  .logo-image {
    width: min(210px, 68vw);
    max-width: 100%;
  }

  .topnav {
    display: flex;
    position: static;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    width: 100%;
    max-width: 100%;
  }

  .topnav a,
  .topnav button {
    border: 1px solid rgba(15, 95, 88, .16);
    border-radius: 999px;
    background: rgba(255, 255, 255, .76);
    padding: 7px 10px;
    line-height: 1.2;
    font-size: 14px;
    white-space: nowrap;
  }

  .topnav button {
    color: var(--primary);
  }

  .page {
    width: min(1180px, calc(100% - 20px));
    max-width: calc(100vw - 20px);
    margin-left: auto;
    margin-right: auto;
    margin-top: 18px;
  }

  .dashboard,
  .panel,
  .page-title,
  .tabs,
  .metric-row {
    min-width: 0;
    max-width: 100%;
  }

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

  .auth-card {
    margin: 28px auto 0;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-title {
    align-items: flex-start;
    gap: 18px;
    padding: 22px;
  }

  .page-title .primary {
    align-self: flex-start;
  }

  .filters,
  .grid.two,
  .settings-status,
  .metric-row {
    grid-template-columns: 1fr;
  }
}

/* Статус "Оплачена" */
.status-paid {
    color: #0f5f58;
    font-weight: 600;
    background-color: #e6f4f2;
    padding: 2px 8px;
    border-radius: 4px;
}


/* Referral link row */
.referral-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 16px;
}

.referral-row .copy-field {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.referral-row .copy-btn {
    flex-shrink: 0;
    align-self: stretch;
    aspect-ratio: 1;
    padding: 0;
    min-width: 0;
    min-height: 0;
}

.client-info {
    line-height: 1.3;
    min-width: 140px;
}

.deals-table th,
.deals-table td {
    vertical-align: middle;
}

.deals-table .nowrap {
    white-space: nowrap;
}

.deals-table .actions-cell {
    white-space: nowrap;
    width: 1%;
}

.deals-table .documents-cell {
    min-width: 220px;
}

.deal-documents {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    min-width: 0;
}

.deal-documents .doc-list {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.deal-documents .doc-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.deal-documents .doc-item a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.deal-documents .doc-empty {
    white-space: nowrap;
}

.deal-documents .inline-upload {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-top: 0;
}

.doc-delete-form {
    margin: 0;
    display: inline-flex;
}

.doc-delete-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
}

.doc-delete-btn:hover {
    color: var(--danger);
}

/* Стили для кнопки загрузки документов */
.inline-upload .upload-btn,
.upload-btn {
    background: #f3f6f4;
    border: 1px solid #d9e2df;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    color: var(--text);
}

.inline-upload .upload-btn:hover,
.upload-btn:hover {
    background: #e8ece9;
    border-color: #c5d0cc;
    color: var(--text);
}

.inline-upload .upload-btn--has-docs,
.upload-btn--has-docs {
    background: #d4f7c4;
    border-color: #8bc34a;
    color: #2e5e1a;
}

.inline-upload .upload-btn--has-docs:hover,
.upload-btn--has-docs:hover {
    background: #c0f0a8;
    border-color: #7cb342;
    color: #2e5e1a;
}

/* Стили для иконки копирования */
.copy-btn {
    background: #f3f6f4;
    border: 1px solid #d9e2df;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.copy-btn:hover {
    background: #e6f4f2;
    border-color: #0f5f58;
}

.copy-btn:disabled {
    cursor: default;
}

.copy-btn svg {
    display: block;
    stroke: currentColor;
}

.upload-btn:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}


