:root {
  --bg-1: #2e1065;
  --bg-2: #4c1d95;
  --accent: #7c3aed;
  --accent-2: #a78bfa;
  --accent-deep: #5b21b6;
  --card: rgba(255, 255, 255, 0.95);
  --text: #27174a;
  --muted: #6e5ea1;
  --line: #e9e2ff;
  --surface: #f8f5ff;
  --surface-2: #f2ecff;
  --ok: #0b8f5a;
  --warn: #ad7f00;
  --bad: #c63434;
  --shadow: 0 18px 48px rgba(43, 16, 101, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 15% 10%, var(--accent-2) 0%, transparent 35%),
    radial-gradient(circle at 85% 20%, #c4b5fd 0%, transparent 30%),
    linear-gradient(125deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.2;
}

.layout {
  width: min(1240px, calc(100% - 2rem));
  margin: 1rem auto 2rem;
  display: grid;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.hidden {
  display: none !important;
}

.auth-shell {
  width: min(560px, calc(100% - 2rem));
  margin: 2.2rem auto;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(124, 58, 237, 0.18);
  padding: 1rem 1.1rem;
  animation: rise 280ms ease-out;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.mono,
code,
th,
select,
button,
input {
  font-family: "IBM Plex Mono", monospace;
}

.kicker {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  font-size: 0.72rem;
}

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

.compact {
  margin-top: 0;
}

.auth-card h1 {
  margin: 0.25rem 0 0.45rem;
  font-size: clamp(1.6rem, 3vw, 2rem);
}

.auth-tabs {
  margin-top: 0.95rem;
  display: flex;
  gap: 0.6rem;
}

.auth-form {
  margin-top: 0.65rem;
}

.auth-actions {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.6rem;
}

.status-message {
  margin-top: 0.55rem;
  font-size: 0.84rem;
}

.status-message a {
  color: #4c1d95;
  font-weight: 700;
}

.status-sent {
  color: var(--ok);
  font-weight: 700;
}

.status-failed {
  color: var(--bad);
  font-weight: 700;
}

label {
  display: block;
  margin-top: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

input,
select,
button {
  border-radius: 10px;
  border: 1px solid #d7c9fb;
  font-size: 0.84rem;
}

input,
select {
  width: 100%;
  padding: 0.62rem 0.66rem;
  background: var(--surface);
}

button {
  padding: 0.6rem 0.75rem;
  background: var(--accent);
  color: #f8fefe;
  border-color: var(--accent-deep);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-deep);
  color: #fff;
}

button.ghost,
.btn-tertiary {
  background: var(--surface);
  color: #4d2b8f;
  border-color: #d6c7fb;
}

button.ghost:hover,
.btn-tertiary:hover {
  color: #fff;
}

.btn {
  font-weight: 700;
}

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

.hero h1 {
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.hero-button-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.hero p {
  margin: 0;
  max-width: 900px;
  color: #3e2d6d;
}

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

.metric h2 {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.metric-list {
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.38rem;
}

.metric-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.38rem 0.5rem;
}

.metric-list span {
  font-size: 0.76rem;
  color: #4d2f87;
}

.metric-list strong {
  font-size: 1rem;
  color: #321a66;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  flex-wrap: wrap;
}

.section-header h2 {
  margin: 0;
}

.comments-header .source-tabs {
  flex: 1;
}

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.source-tab {
  border: 1px solid rgba(124, 58, 237, 0.26);
  border-radius: 999px;
  background: var(--surface);
  color: #4b1f97;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.42rem 0.8rem;
  cursor: pointer;
}

.source-tab.is-active {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff;
}

.filter-row {
  margin-left: auto;
  min-width: min(420px, 100%);
}

.table-wrap {
  overflow: auto;
}

.comment-groups {
  display: grid;
  gap: 0.9rem;
}

.comment-group {
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 14px;
  background: rgba(248, 245, 255, 0.62);
  padding: 0.7rem;
}

.comment-group > summary {
  cursor: pointer;
  list-style: none;
}

.comment-group > summary::-webkit-details-marker {
  display: none;
}

.group-summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.group-summary-main {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.group-summary::after {
  content: "▾";
  margin-left: auto;
  color: #4c1d95;
}

.comment-group[open] .group-summary::after {
  content: "▴";
}

.group-open .group-summary-title {
  color: #b45309;
}

.group-resolved .group-summary-title {
  color: #0b6d46;
}

.group-open .board-count {
  background: #fff3d9;
  color: #8a6210;
}

.group-resolved .board-count {
  background: #dff7ec;
  color: #0b6d46;
}

.board-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(124, 58, 237, 0.18);
  color: #4c1d95;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
}

th {
  color: #4d2f87;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: var(--surface-2);
}

.discussion-kind {
  font-size: 0.72rem;
  color: #4d2f87;
  font-weight: 700;
}

.comment-cell {
  max-width: 540px;
  white-space: normal;
  line-height: 1.45;
}

.discussion-list {
  display: grid;
  gap: 0.45rem;
}

.discussion-item {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.42rem 0.5rem;
}

.discussion-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
  font-size: 0.74rem;
}

.discussion-meta-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.discussion-delete-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  border: 1px solid rgba(124, 58, 237, 0.3);
  background: #fff;
  color: #5b21b6;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
}

.discussion-delete-btn:hover {
  transform: none;
  background: #f3ebff;
}

.discussion-delete-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.discussion-text {
  white-space: pre-wrap;
  line-height: 1.45;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.table-link {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.58rem;
  border: 1px solid rgba(124, 58, 237, 0.24);
  background: rgba(167, 139, 250, 0.2);
  color: #4a1b95;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
}

.table-link:hover {
  background: rgba(124, 58, 237, 0.24);
  color: #fff;
}

.empty-col {
  margin: 0.4rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.logs-dropdown summary {
  cursor: pointer;
  font-weight: 700;
  color: #3d2572;
  list-style: none;
}

.logs-dropdown summary::-webkit-details-marker {
  display: none;
}

.logs-dropdown summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 120ms ease;
}

.logs-dropdown[open] summary::before {
  transform: rotate(90deg);
}

.logs-wrap {
  margin-top: 0.65rem;
}

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

  .hero-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    width: 100%;
    align-items: flex-start;
  }

  .filter-row {
    min-width: 100%;
    margin-left: 0;
  }

  .comments-header .source-tabs {
    flex: 0 0 100%;
  }
}

@media (max-width: 620px) {
  .layout {
    width: calc(100% - 1rem);
  }

  .card {
    padding: 0.85rem;
    border-radius: 14px;
  }
}
