:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f6;
  --ink: #16222b;
  --muted: #60707c;
  --line: #d8e1e7;
  --brand: #007f73;
  --brand-strong: #005f56;
  --accent: #d64646;
  --warning: #f2b84b;
  --shadow: 0 18px 50px rgba(21, 35, 45, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  gap: 20px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
}

.brand-mark {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(17, 31, 39, .1);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small,
.eyebrow,
.muted,
.meta {
  color: var(--muted);
}

.topnav {
  display: inline-flex;
  gap: 6px;
  justify-self: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.topnav a {
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.topnav a.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 32, 40, .08);
}

.session-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.forum-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 28px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 12px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: .94;
}

.forum-hero p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 0;
  color: #43515b;
  font-size: 18px;
  line-height: 1.55;
}

.notice {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(22, 34, 43, .07);
}

.notice span {
  color: var(--muted);
  line-height: 1.45;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(22, 34, 43, .08);
}

label {
  display: grid;
  gap: 7px;
  color: #34444f;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 127, 115, .16);
}

.btn,
.icon-btn,
.tab {
  border: 0;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 800;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

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

.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
}

.btn.danger {
  background: #fff0f0;
  color: #9b2424;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.btn.full {
  width: 100%;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 900;
  padding: 0;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  margin-top: 22px;
}

.admin-mode {
  background: #eef4f7;
}

.admin-mode .topbar {
  border-bottom-color: #1f5560;
  background: rgba(16, 49, 58, .96);
  color: #f7fbfc;
}

.admin-mode .brand small,
.admin-mode .topnav a,
.admin-mode .meta {
  color: #b8ccd1;
}

.admin-mode .brand-mark {
  background: #ffffff;
}

.admin-mode .topnav {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .08);
}

.admin-mode .topnav a.active {
  background: #f7fbfc;
  color: #12313a;
}

.admin-mode .forum-hero,
.admin-mode .control-strip,
.admin-mode .thread-list-panel {
  display: none;
}

.admin-mode .main-grid {
  display: block;
}

.admin-mode .side-panel {
  width: 100%;
  border-color: #c6d8de;
  background: transparent;
}

.user-mode .main-grid {
  grid-template-columns: 1fr;
}

.user-mode .side-panel {
  order: -1;
  width: 100%;
  border-color: #cfdce1;
}

.user-mode .thread-list-panel {
  margin-top: 0;
}

.thread-list-panel,
.side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.thread-list {
  display: grid;
}

.thread-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.thread-card:last-child {
  border-bottom: 0;
}

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

.thread-card p {
  margin: 0;
  color: #43515b;
  line-height: 1.48;
}

.thread-topline,
.thread-meta,
.thread-actions,
.comment-meta,
.panel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.thread-actions {
  justify-content: space-between;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #43515b;
  font-size: 12px;
  font-weight: 900;
}

.tag.offer {
  background: #e3f5f1;
  color: #006a5f;
}

.tag.demand {
  background: #fff4da;
  color: #8a5c00;
}

.tag.status-approved {
  background: #e3f5f1;
  color: #006a5f;
}

.tag.status-pending {
  background: #fff4da;
  color: #8a5c00;
}

.tag.status-rejected {
  background: #fff0f0;
  color: #9b2424;
}

.side-panel {
  align-self: start;
  overflow: hidden;
}

.dashboard-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.admin-dashboard {
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 18px;
  padding: 0;
}

.user-dashboard {
  grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr);
  gap: 18px;
}

.admin-console-hero,
.user-console-hero,
.admin-metrics,
.user-metrics,
.admin-shortcuts,
.user-shortcuts,
.admin-wide,
.admin-config,
.user-threads-panel {
  grid-column: 1 / -1;
}

.admin-console-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 24px;
  border: 1px solid #bfd5dc;
  border-radius: 8px;
  background: #12313a;
  color: #f7fbfc;
}

.admin-console-hero h3 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 40px);
}

.admin-console-hero p {
  margin: 0;
  color: #c9dbe0;
}

.user-console-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px;
  border: 1px solid #c9dbe0;
  border-radius: 8px;
  background: #ffffff;
}

.user-console-hero h3 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 38px);
}

.user-console-hero p {
  margin: 0;
  color: var(--muted);
}

.admin-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 7px;
  background: rgba(255, 255, 255, .12);
  color: #ffffff;
  font-weight: 900;
}

.user-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid #b9d9d5;
  border-radius: 7px;
  background: #e3f5f1;
  color: #006a5f;
  font-weight: 900;
}

.admin-metrics,
.user-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 4px;
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--metric-border, #bfd5dc);
  border-radius: 8px;
  background: var(--metric-bg, #ffffff);
  color: var(--metric-ink, var(--ink));
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 26px rgba(34, 49, 58, .06);
}

.metric-card strong {
  font-size: 32px;
  line-height: 1;
}

.metric-card span {
  color: var(--metric-label, var(--muted));
  font-weight: 900;
}

.metric-pending {
  --metric-bg: #fff8e9;
  --metric-border: #f2cc7d;
  --metric-ink: #8a5c00;
  --metric-label: #755018;
}

.metric-approved {
  --metric-bg: #edf9f4;
  --metric-border: #a8d9c4;
  --metric-ink: #006a43;
  --metric-label: #24634c;
}

.metric-rejected {
  --metric-bg: #fff1f1;
  --metric-border: #efb2b2;
  --metric-ink: #9d2525;
  --metric-label: #843333;
}

.metric-users,
.metric-notices {
  --metric-bg: #eef5ff;
  --metric-border: #b8cffa;
  --metric-ink: #254d9f;
  --metric-label: #3c5687;
}

.metric-notices {
  --metric-bg: #fff4dc;
  --metric-border: #f0bd59;
  --metric-ink: #9a6500;
  --metric-label: #755018;
}

.admin-shortcuts,
.user-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-metric {
  border-color: #c9dbe0;
}

.panel-box {
  --panel-accent: #d8e1e7;
  --panel-bg: #fbfcfd;
  position: relative;
  display: grid;
  gap: 8px;
  overflow: hidden;
  padding: 14px 14px 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: 0 12px 32px rgba(19, 35, 45, .06);
}

.panel-box::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--panel-accent);
  content: "";
}

.panel-box > * {
  position: relative;
}

.panel-account {
  --panel-accent: #168f7f;
  --panel-bg: #f2fbf8;
}

.panel-security {
  --panel-accent: #d85252;
  --panel-bg: #fff7f7;
}

.panel-threads {
  --panel-accent: #397ee6;
  --panel-bg: #f4f8ff;
}

.panel-notices {
  --panel-accent: #e6a42d;
  --panel-bg: #fff9ea;
}

.panel-moderation {
  --panel-accent: #e6a42d;
  --panel-bg: #fffaf0;
}

.panel-users {
  --panel-accent: #397ee6;
  --panel-bg: #f5f9ff;
}

.panel-searches {
  --panel-accent: #168f7f;
  --panel-bg: #f4fbf8;
}

.panel-config {
  --panel-accent: #59606d;
  --panel-bg: #f7f8fa;
}

.panel-box h3 {
  margin: 0;
  font-size: 15px;
}

.panel-box p,
.panel-box li {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.panel-box ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-form {
  display: grid;
  gap: 10px;
}

.compact-form input {
  min-height: 38px;
}

.admin-panel {
  gap: 12px;
}

.admin-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-section-head h3 {
  font-size: 20px;
}

.admin-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px;
  gap: 12px;
}

.admin-thread-list,
.admin-user-list {
  display: grid;
  gap: 10px;
}

.admin-item {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-item strong {
  overflow-wrap: anywhere;
}

.admin-user-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.admin-user-head strong,
.admin-user-head span {
  display: block;
}

.user-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.user-data-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-data-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.user-data-grid strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

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

.inbox-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #e1cfa4;
  border-radius: 8px;
  background: #fff;
}

.inbox-item.unread {
  border-color: #d99415;
  background: #fff6de;
  box-shadow: inset 4px 0 0 #d99415;
}

.notification-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
}

.notification-heading > div {
  min-width: 0;
  flex: 1;
}

.bell-icon {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid #e5b24d;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 18px rgba(154, 101, 0, .12);
}

.bell-icon::before {
  position: absolute;
  top: 9px;
  left: 11px;
  width: 12px;
  height: 13px;
  border: 2px solid #9a6500;
  border-bottom: 0;
  border-radius: 12px 12px 5px 5px;
  content: "";
}

.bell-icon::after {
  position: absolute;
  left: 14px;
  bottom: 9px;
  width: 10px;
  height: 5px;
  border-radius: 999px;
  background: #9a6500;
  content: "";
}

.bell-count {
  display: inline-grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #184d47;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.inbox-topline {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.inbox-topline strong {
  overflow-wrap: anywhere;
  color: var(--ink);
}

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

.service-toggles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.service-toggles label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.service-toggles input {
  width: auto;
  min-height: auto;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

#threadModal,
#threadDetailModal {
  width: min(760px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(9, 20, 27, .54);
  backdrop-filter: blur(3px);
}

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

.modal-card.wide,
.modal-card.detail {
  width: 100%;
}

.modal-card.detail {
  max-height: min(84vh, 860px);
  overflow: auto;
}

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

.modal-head h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.icon-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 32, 40, .08);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #a32727;
  font-size: 14px;
  font-weight: 800;
}

.form-hint {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f0bd59;
  border-radius: 8px;
  background: #fff8e9;
  color: #755018;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

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

.comment {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.comment.blocked-comment {
  border-style: dashed;
  background: #f6f8f9;
}

.comment p {
  margin: 8px 0 0;
  line-height: 1.45;
}

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

.owner-tools {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.soon-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f7f9 0%, #e7f2ef 58%, #fff6e1 100%);
}

.soon-shell {
  width: min(940px, 100%);
}

.soon-panel {
  padding: clamp(28px, 8vw, 72px);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow);
}

.soon-panel h1 {
  margin-bottom: 14px;
}

.lead {
  max-width: 620px;
  color: #43515b;
  font-size: 20px;
  line-height: 1.5;
}

.soon-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 26px;
}

.status-pill {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .topbar,
  .forum-hero,
  .control-strip,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .topnav,
  .session-actions {
    justify-self: stretch;
  }

  .topnav a,
  .session-actions .btn {
    flex: 1;
  }

  .forum-hero {
    align-items: start;
  }

  .admin-dashboard,
  .admin-metrics,
  .user-dashboard,
  .user-metrics,
  .admin-filters,
  .user-data-grid,
  .user-data-grid.compact,
  .service-toggles {
    grid-template-columns: 1fr;
  }

  .admin-console-hero,
  .user-console-hero {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin-top: 18px;
  }

  .topbar {
    padding: 12px 10px;
  }

  h1 {
    font-size: 38px;
  }

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

  .admin-shortcuts .btn,
  .user-shortcuts .btn,
  .owner-tools .btn,
  .panel-row .btn {
    width: 100%;
  }
}
