:root {
  --bg: #090807;
  --panel: #14110f;
  --panel2: #1c1713;
  --line: #3c3026;
  --gold: #b68a45;
  --gold2: #d0ad67;
  --text: #f2ece3;
  --muted: #a79c90;
  --danger: #c45b4d;
  --ok: #7ca982;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(182, 138, 69, 0.12), transparent 28%),
    linear-gradient(135deg, #090807 0%, #15110e 45%, #070707 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 42px;
  border-bottom: 1px solid rgba(182, 138, 69, 0.24);
  background: rgba(9, 8, 7, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, #2b2118, #b68a45);
}

.nav {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
}

.nav a:hover {
  color: var(--gold2);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 80px;
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 24px;
  min-height: 520px;
  align-items: stretch;
}

.hero-panel,
.hero-card,
.panel {
  border: 1px solid rgba(182, 138, 69, 0.26);
  background: linear-gradient(145deg, rgba(28, 23, 19, 0.96), rgba(13, 11, 10, 0.96));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.hero-panel {
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-card {
  padding: 32px;
  display: grid;
  gap: 16px;
  align-content: center;
}

.eyebrow {
  color: var(--gold2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.94;
  max-width: 860px;
}

h2 {
  margin: 0 0 12px;
  font-size: 28px;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.hero-panel p {
  max-width: 720px;
  font-size: 18px;
  margin: 24px 0 0;
}

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

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 13px 18px;
  min-height: 46px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 4px;
}

.btn-primary {
  border-color: var(--gold);
  background: linear-gradient(135deg, #b68a45, #7e5d29);
  color: #100c08;
}

.btn-secondary {
  border-color: var(--gold);
  color: var(--gold2);
}

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

.btn:hover {
  filter: brightness(1.08);
}

.metric {
  border-left: 2px solid var(--gold);
  padding: 18px 0 18px 18px;
  background: rgba(255, 255, 255, 0.02);
}

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

.metric strong {
  font-size: 18px;
}

.grid-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.panel {
  padding: 28px;
  margin-top: 24px;
}

.wide {
  width: 100%;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

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

.form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

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

.form textarea,
.form input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b0a09;
  color: var(--text);
  padding: 14px 14px;
  border-radius: 4px;
  outline: none;
}

.form textarea {
  min-height: 110px;
  resize: vertical;
  grid-column: 1 / -1;
}

.form input:focus,
.form textarea:focus {
  border-color: var(--gold);
}

.check {
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.card {
  border: 1px solid rgba(182, 138, 69, 0.24);
  background: linear-gradient(145deg, #171310, #0e0d0c);
  padding: 20px;
  min-height: 210px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 19px;
}

.card p {
  margin: 8px 0;
  font-size: 14px;
}

.badge {
  display: inline-flex;
  border: 1px solid rgba(182, 138, 69, 0.34);
  color: var(--gold2);
  padding: 5px 8px;
  font-size: 12px;
  margin: 4px 4px 4px 0;
}

.status-box {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 280px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #090807;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 380px;
  padding: 16px 18px;
  border: 1px solid var(--gold);
  background: #15110e;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  display: none;
}

@media (max-width: 920px) {
  .topbar {
    padding: 0 18px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
  }

  .nav {
    gap: 12px;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 8px;
  }

  .hero,
  .grid-section,
  .form.columns,
  .cards {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    padding: 34px 24px;
  }

  h1 {
    font-size: 42px;
  }
}

/* STEP 4: строгие элементы загрузки файлов и превью */
.file-label {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(182, 138, 69, 0.24);
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
  color: var(--muted);
  border-radius: 4px;
}

.file-label span {
  color: var(--gold2);
  font-size: 13px;
}

.file-label input {
  padding: 10px;
}

.card-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border: 1px solid rgba(182, 138, 69, 0.22);
  margin-bottom: 14px;
  background: #090807;
}

.media-line {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

/* STEP 5: сообщения, отклики, баланс */
.message-box {
  margin-top: 18px;
  border: 1px solid rgba(182, 138, 69, 0.24);
  background: #0b0a09;
  padding: 18px;
  display: none;
}

.message-thread {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 6px;
}

.message-item {
  border-left: 2px solid var(--line);
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
}

.message-item.mine {
  border-left-color: var(--gold);
}

.message-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.message-form input {
  border: 1px solid var(--line);
  background: #090807;
  color: var(--text);
  padding: 13px;
  border-radius: 4px;
}

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

/* STEP 8: модальное окно детальной карточки кейса */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: min(880px, 100%);
  max-height: 86vh;
  overflow: auto;
  border: 1px solid rgba(182, 138, 69, 0.36);
  background: linear-gradient(145deg, #171310, #0a0908);
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
  padding: 26px;
  border-radius: 4px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.locked-box {
  border: 1px solid rgba(182, 138, 69, 0.32);
  background: rgba(182, 138, 69, 0.06);
  padding: 18px;
  margin-top: 16px;
}

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

.detail-cell {
  border: 1px solid rgba(182, 138, 69, 0.22);
  background: rgba(255,255,255,.02);
  padding: 14px;
}

.detail-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.detail-cell strong {
  color: var(--text);
}

@media (max-width: 720px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 18px;
  }
}

/* STEP 11: фильтры и мониторинг биржи */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stat-card {
  border: 1px solid rgba(182, 138, 69, 0.24);
  background: linear-gradient(145deg, #171310, #0b0a09);
  padding: 18px;
  border-radius: 4px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.stat-card strong {
  display: block;
  color: var(--text);
  font-size: 26px;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 18px;
  padding: 14px;
  border: 1px solid rgba(182, 138, 69, 0.18);
  background: rgba(255,255,255,0.02);
}

.filter-form input {
  border: 1px solid var(--line);
  background: #090807;
  color: var(--text);
  padding: 12px;
  border-radius: 4px;
}

@media (max-width: 920px) {
  .stat-grid,
  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .stat-grid,
  .filter-form {
    grid-template-columns: 1fr;
  }
}

/* STEP 13: профиль и аватар */
.profile-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.profile-avatar-box {
  border: 1px solid rgba(182, 138, 69, 0.24);
  background: rgba(255,255,255,0.02);
  padding: 16px;
  border-radius: 4px;
}

.profile-avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(182, 138, 69, 0.28);
  background: #090807;
  margin-bottom: 14px;
}

.profile-avatar[src=""] {
  display: none;
}

.grid-form select {
  border: 1px solid var(--line);
  background: #090807;
  color: var(--text);
  padding: 13px;
  border-radius: 4px;
}

@media (max-width: 820px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }

  .profile-avatar-box {
    max-width: 320px;
  }
}

/* STEP 18: владелец публикации в карточках */
.card-owner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid rgba(182, 138, 69, 0.18);
  background: rgba(255,255,255,0.02);
}

.card-owner-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: cover;
  border: 1px solid rgba(182, 138, 69, 0.34);
  background: #090807;
}

.card-owner-avatar.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 10px;
}

.card-owner strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

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

/* STEP 19: разделение публичной части, входа, регистрации и личного кабинета */
.invest-route-hidden {
  display: none !important;
}

.invest-route-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(8, 7, 6, 0.94);
  border-bottom: 1px solid rgba(182, 138, 69, 0.24);
  backdrop-filter: blur(10px);
}

.invest-route-nav-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.invest-route-brand {
  color: #f3e6cf;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.invest-route-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.invest-route-actions a,
.invest-route-actions button {
  appearance: none;
  border: 1px solid rgba(182, 138, 69, 0.34);
  background: #0d0b09;
  color: #f3e6cf;
  text-decoration: none;
  padding: 10px 13px;
  border-radius: 3px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.invest-route-actions a:hover,
.invest-route-actions button:hover {
  border-color: rgba(214, 170, 92, 0.78);
  background: #17110c;
}

body[data-invest-route="login"] main,
body[data-invest-route="register"] main,
body[data-invest-route="cabinet"] main {
  padding-top: 28px;
}

body[data-invest-route="login"] section:not(.invest-route-hidden),
body[data-invest-route="register"] section:not(.invest-route-hidden) {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.invest-cabinet-guard {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 720px) {
  .invest-route-nav-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .invest-route-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .invest-route-actions a,
  .invest-route-actions button {
    flex: 1 1 auto;
    text-align: center;
  }
}
