:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #68737d;
  --line: #dde4ea;
  --panel: #ffffff;
  --page: #f5f7f8;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --amber: #b7791f;
  --red: #b42318;
  --green: #1f7a4d;
  --violet: #5b4b9a;
  --blue: #2563a6;
  --shadow: 0 14px 38px rgba(23, 32, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(245, 247, 248, 0) 320px),
    var(--page);
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(221, 228, 234, 0.86);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--ink);
  font-size: 22px;
  font-weight: 780;
  letter-spacing: 0;
}

.brand:hover {
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: #40505b;
  font-size: 14px;
  font-weight: 640;
  white-space: nowrap;
}

.nav a:hover,
.nav a.active {
  background: #e7f3f1;
  color: var(--teal-strong);
  text-decoration: none;
}

.nav-public {
  justify-content: flex-end;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  gap: 32px;
  align-items: center;
  min-height: calc(100vh - 120px);
  padding: 28px 0 48px;
}

.hero-copy h1,
.page-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: 48px;
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy p,
.page-title p {
  max-width: 62ch;
  margin: 18px 0 0;
  color: #4c5a64;
  font-size: 18px;
  line-height: 1.65;
}

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

.signal-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.signal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.signal-flow {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.signal-item {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid #e7edf2;
  border-radius: 8px;
  background: #fbfcfd;
}

.signal-item strong {
  color: var(--ink);
}

.signal-item span {
  color: var(--muted);
  line-height: 1.48;
}

.signal-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: #f1f8f6;
  color: var(--teal-strong);
  font-weight: 760;
}

.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

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

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

.card,
.form-panel,
.table-panel,
.empty,
.match-panel,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(23, 32, 38, 0.04);
}

.card {
  padding: 20px;
}

.card h2,
.form-panel h2,
.table-panel h2,
.match-panel h2,
.chat-panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
  letter-spacing: 0;
}

.card p,
.empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.stat {
  display: block;
  margin: 12px 0 4px;
  font-size: 34px;
  font-weight: 780;
}

.form-panel {
  max-width: 760px;
  padding: 24px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #34434e;
  font-weight: 680;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd9e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 11px 12px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

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

.radio-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px;
  border: 1px solid #cfd9e1;
  border-radius: 8px;
  background: #fff;
}

.radio-row input {
  width: auto;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.button:hover,
button:hover {
  background: var(--teal-strong);
  text-decoration: none;
}

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

.button.secondary,
button.secondary {
  border-color: #cbd6dd;
  background: #fff;
  color: #34434e;
}

.button.secondary:hover,
button.secondary:hover {
  background: #f0f4f6;
}

.button.warning,
button.warning {
  border-color: var(--amber);
  background: var(--amber);
}

.button.danger,
button.danger {
  border-color: var(--red);
  background: var(--red);
}

.button.small,
button.small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.flash {
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid #cbd6dd;
  border-radius: 8px;
  background: #fff;
  color: #34434e;
  line-height: 1.45;
}

.flash.success {
  border-color: #a7d8c3;
  background: #effaf4;
  color: var(--green);
}

.flash.error {
  border-color: #efb6b1;
  background: #fff3f2;
  color: var(--red);
}

.flash.info {
  border-color: #bcd3ee;
  background: #f0f6ff;
  color: var(--blue);
}

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

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

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

th {
  color: #596773;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  color: #26333c;
  line-height: 1.45;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f5;
  color: #44525e;
  font-size: 12px;
  font-weight: 760;
}

.badge.active,
.badge.accepted,
.badge.chat_opened {
  background: #e7f6ef;
  color: var(--green);
}

.badge.needs_review,
.badge.pending {
  background: #fff6df;
  color: var(--amber);
}

.badge.deleted,
.badge.declined,
.badge.inactive {
  background: #fff0ef;
  color: var(--red);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.meta-grid div {
  padding: 10px 12px;
  border: 1px solid #e7edf2;
  border-radius: 8px;
  background: #fbfcfd;
}

.meta-grid dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.meta-grid dd {
  margin: 0;
  color: var(--ink);
}

.match-list,
.request-list,
.chat-list {
  display: grid;
  gap: 16px;
}

.match-panel,
.chat-panel {
  padding: 20px;
}

.match-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.score {
  color: var(--violet);
  font-size: 26px;
  font-weight: 800;
}

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

.snippet {
  padding: 14px;
  border: 1px solid #e5ebf0;
  border-radius: 8px;
  background: #fbfcfd;
  color: #33424c;
  line-height: 1.5;
}

.explain {
  margin: 16px 0 0;
  padding-left: 20px;
  color: #3e4d58;
  line-height: 1.6;
}

.empty {
  padding: 28px;
}

.chat-messages {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 16px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf8f6;
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 720;
}

.chat-status[data-mode="warn"] {
  background: #fff6df;
  color: var(--amber);
}

.chat-status[data-mode="poll"] {
  background: #eef2f5;
  color: #44525e;
}

.message {
  width: min(680px, 92%);
  padding: 12px 14px;
  border: 1px solid #dbe4eb;
  border-radius: 8px;
  background: #fff;
}

.message.own {
  justify-self: end;
  border-color: #b8ded8;
  background: #edf8f6;
}

.message-body {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.admin-section {
  margin-top: 22px;
}

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

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .account {
    width: 100%;
    justify-content: space-between;
  }

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

  .hero {
    min-height: auto;
  }

  .hero-copy h1,
  .page-title h1 {
    font-size: 38px;
  }

  .page-title {
    display: grid;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .hero-copy h1,
  .page-title h1 {
    font-size: 32px;
  }

  .radio-row,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px;
  }
}
