* {
  box-sizing: border-box;
}

:root {
  --bg: #dde4eb;
  --surface: #ffffff;
  --surface-2: #f8fbfc;
  --line: #d9dfe4;
  --line-soft: #e9edf0;
  --text: #17191c;
  --muted: #7b828a;
  --accent: #0c5a14;
  --accent-dark: #0c5a14;
  --accent-soft: #eefcf9;
  --green: #279a38;
  --red: #d93a00;
  --shadow-card: 0 10px 24px rgba(25, 35, 45, 0.04);
  --shadow-pop: 0 20px 40px rgba(22, 29, 37, 0.1);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.65;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

/* HEADER */

.site-header {
  height: 72px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 500;
  backdrop-filter: blur(10px);
}

.header-inner {
  height: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 20px 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.brand-name-img {
  height: 30px;
  width: auto;
  object-fit: contain;
  display: block;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a,
.nav button,
.primary-button,
.secondary-button,
button[type="submit"],
.load-more-feed,
.load-more-comments {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button,
button[type="submit"] {
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: #ffffff;
  color: var(--accent-dark);
}

/* LAYOUT */

.app-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 22px 20px 28px 44px;
}

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

.main-column,
.side-column {
  min-width: 0;
}

.content-card,
.composer-card,
.post-card,
.auth-card,
.ratings-card,
.profile-hero,
.portfolio-summary,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.content-card {
  padding: 18px;
  margin-bottom: 18px;
}

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

.section-header h1,
.section-header h2 {
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text);
}

.section-header h1 {
  font-size: 28px;
}

.section-header h2 {
  font-size: 19px;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
}

.muted {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.55;
}

/* AUTH */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 26px;
}

.auth-card .brand {
  margin-bottom: 26px;
}

.auth-card h1 {
  margin: 0 0 10px;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.auth-card p {
  margin: 0 0 22px;
  color: #4f535a;
  font-size: 14px;
  line-height: 1.55;
  font-weight: 600;
}

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

.auth-form label,
.profile-edit-form label,
.trade-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.auth-form input,
.profile-edit-form input,
.profile-edit-form textarea,
.trade-form input,
.trade-form select,
textarea,
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.auth-form input,
.trade-form input,
.trade-form select,
.search-wrap input {
  height: 46px;
  border-radius: 12px;
  padding: 0 14px;
}

textarea {
  border-radius: 14px;
  padding: 14px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 203, 187, 0.08);
}

.auth-switch {
  margin-top: 18px !important;
  margin-bottom: 0 !important;
}

.auth-switch a {
  color: var(--accent-dark);
  font-weight: 900;
}

/* COMPOSER */

.composer-card {
  padding: 14px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfefe 100%);
}

.composer-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.composer-row form {
  flex: 1;
  min-width: 0;
}

.composer-row textarea {
  min-height: 104px;
  font-size: 16px;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.composer-extra {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.file-button {
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #8a8f94;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  display: none;
}

/* SEARCH */

.search-wrap {
  position: relative;
  min-width: 220px;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  z-index: 650;
  box-shadow: var(--shadow-pop);
}

.search-result {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  background: #ffffff;
  display: grid;
  gap: 3px;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover {
  background: #fbfdfd;
}

.search-result strong {
  font-size: 14px;
  font-weight: 900;
}

.search-result span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* AVATARS */

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #21d0c1 0%, #0faea0 100%);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.avatar-sm {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.avatar-md {
  width: 46px;
  height: 46px;
  font-size: 18px;
}

.avatar-xl {
  width: 112px;
  height: 112px;
  font-size: 36px;
  border: 4px solid #ffffff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}

/* FEED / POSTS */

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

.post-card {
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fdfefe 100%);
  display: flex;
  gap: 12px;
  position: relative;
}

.post-main {
  flex: 1;
  min-width: 0;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.post-author {
  font-size: 15px;
  font-weight: 900;
  color: var(--text);
}

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

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

.ticker-chip {
  margin-left: 4px;
  border: 1px solid #dce8e4;
  background: #f7fffc;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 900;
  color: var(--accent-dark);
  white-space: nowrap;
}

.post-body {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  color: var(--text);
}

.post-image {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  margin: 4px 0 12px;
}

.post-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 22px;
  font-size: 14px;
  font-weight: 800;
  color: #868b90;
}

.post-action {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  color: var(--accent-dark);
  font-weight: 800;
}

.post-action img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.post-action.is-liked {
  color: var(--green);
}

.comment-icon {
  font-size: 15px;
}

.post-menu-wrap {
  position: relative;
  margin-left: auto;
}

.icon-button {
  border: 0;
  background: transparent;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  color: #6f757d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.icon-button:hover {
  background: #f6f8f9;
}

.post-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  z-index: 50;
}

.post-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: #ffffff;
  padding: 13px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.post-menu button:hover {
  background: #fbfdfd;
}

.danger {
  color: var(--red) !important;
}

/* COMMENTS */

.comments-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.comment-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.comment-form textarea {
  flex: 1;
  min-height: 74px;
}

.comment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
  margin-left: calc(var(--depth, 0) * 22px);
}

.comment-bubble {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px 14px;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.comment-header a {
  color: var(--text);
  font-weight: 900;
}

.comment-body {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.text-button.is-liked {
  color: var(--green);
}

.reply-form {
  margin-top: 10px;
}

.comment-replies {
  margin-top: 10px;
}

/* TICKER */

.ticker-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
}

.ticker-hero h1 {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.ticker-hero p {
  margin: 0;
  color: #50565c;
  font-weight: 700;
}

.ticker-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ticker-meta span {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7fafb;
  color: #5f6670;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

/* RATINGS */

.ratings-card {
  padding: 18px;
  margin-bottom: 18px;
}

.rating-grid {
  display: grid;
  gap: 12px;
}

.rating-box {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfefe 100%);
}

.rating-box-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.rating-box-top span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.rating-box-top strong {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.rating-label,
.rating-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

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

.rating-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

/* PROFILE */

.profile-hero {
  overflow: hidden;
  margin-bottom: 18px;
  padding: 0;
}

.profile-hero::before {
  content: "";
  display: block;
  height: 190px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fffd 45%, #dffbf4 100%);
  border-bottom: 1px solid var(--line-soft);
}

.profile-avatar-wrap {
  margin: -54px 20px 0;
}

.profile-info {
  padding: 14px 20px 20px;
}

.profile-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.profile-title-row h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
}

.profile-title-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.profile-bio {
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.6;
  color: #43484d;
  white-space: pre-wrap;
  max-width: 800px;
}

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.profile-stats strong {
  color: var(--text);
  margin-right: 6px;
  font-weight: 900;
}

.profile-edit-form {
  margin: 0 20px 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* PORTFOLIO */

.portfolio-summary {
  padding: 18px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfefe 100%);
}

.metric-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-card strong {
  font-size: 30px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
}

.hero-metric {
  grid-column: span 2;
}

.trade-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

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

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

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

th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
  font-weight: 900;
}

td {
  font-weight: 700;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

/* STATES */

.loading-state,
.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.empty-state p {
  margin: 0;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d8eeee;
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin 0.8s linear infinite;
}

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

.form-error {
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
  min-height: 20px;
  margin: 8px 0 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  border-radius: 14px;
  padding: 13px 16px;
  color: var(--text);
  font-weight: 800;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-type="error"] {
  border-color: #f2b9a6;
  color: var(--red);
}

.image-upload-preview,
.image-preview {
  margin-top: 10px;
}

.image-upload-preview img,
.image-preview {
  max-height: 220px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  object-fit: cover;
}

/* RESPONSIVE */

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

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

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

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

@media (max-width: 680px) {
  .header-inner {
    padding: 0 12px;
  }

  .brand-name-img {
    display: none;
  }

  .app-shell {
    padding: 16px 12px 24px;
  }

  .site-header {
    height: auto;
    min-height: 72px;
  }

  .header-inner {
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .nav {
    width: 100%;
  }

  .post-card,
  .composer-row {
    align-items: flex-start;
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .ticker-hero {
    grid-template-columns: 1fr;
  }

  .ticker-meta {
    justify-content: flex-start;
  }

  .portfolio-summary,
  .trade-form {
    grid-template-columns: 1fr;
  }

  .hero-metric {
    grid-column: span 1;
  }
}