:root {
  --ink: #10231f;
  --muted: #5d736d;
  --line: #d7e3de;
  --panel: rgba(255, 255, 255, 0.88);
  --bg: #eef5f1;
  --accent: #0f766e;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(16, 35, 31, 0.08);
  --radius: 18px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Syne", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #d9f3ea 0%, transparent 40%),
    radial-gradient(circle at top right, #f3ead7 0%, transparent 35%),
    linear-gradient(180deg, #f7fbf8 0%, var(--bg) 100%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 20%, transparent 90%);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

h1, h2, h3, h4 {
  font-family: var(--display);
  margin: 0;
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.2rem; }

.topbar-actions, .modal-actions, .panel-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.load-more-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 18px 20px 22px;
}

.detail-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.detail-item span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.detail-item strong {
  font-size: 14px;
  word-break: break-word;
}

a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat.danger strong { color: var(--danger); }

.badge-muted {
  background: #ece7df;
  color: #6b5e4e;
}

.row-inactive td {
  opacity: 0.7;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  display: grid;
  gap: 12px;
}

.login-card h1 {
  margin: 0;
}

.error-text {
  color: var(--danger);
  margin: 0;
  font-size: 13px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.stat strong {
  display: block;
  font-family: var(--display);
  font-size: 1.8rem;
  margin-top: 4px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.panel-head {
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head.compact {
  padding: 0 0 12px;
  border: 0;
}

.panel-head input {
  width: min(280px, 100%);
}

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

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

textarea { resize: vertical; line-height: 1.5; }

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

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

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

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

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(15, 118, 110, 0.04);
}

tr:hover td { background: rgba(15, 118, 110, 0.03); }

.app-cell strong { display: block; }
.app-cell span, .muted, .hint { color: var(--muted); font-size: 13px; font-weight: 400; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

.btn, .icon-btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
}

.btn.small { padding: 7px 12px; font-size: 12px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #0b5f59; transform: translateY(-1px); }
.btn.ghost { background: #e5efeb; color: var(--ink); }
.btn.ghost:hover { background: #d7e6e1; }
.btn.danger { background: #fee4e2; color: var(--danger); }
.btn.danger:hover { background: #fecdca; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e8efeb;
  font-size: 22px;
  line-height: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #d9f3ea;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 24px);
}

.modal::backdrop {
  background: rgba(16, 35, 31, 0.45);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(720px, 100vw - 24px);
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: rise 0.22s ease;
}

.modal.wide .modal-card { width: min(980px, 100vw - 24px); }

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.spacer { flex: 1; }

.token-box {
  display: flex;
  gap: 10px;
  align-items: start;
  background: #10231f;
  color: #dff7ef;
  border-radius: 16px;
  padding: 16px;
}

.token-box code {
  flex: 1;
  word-break: break-all;
  font-size: 13px;
  line-height: 1.5;
}

.replies-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  min-height: 420px;
}

.replies-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 460px;
  overflow: auto;
}

.replies-list button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
}

.replies-list button.active,
.replies-list button:hover {
  border-color: var(--accent);
  background: #e8f7f2;
}

.replies-list strong { display: block; font-size: 14px; }
.replies-list span { color: var(--muted); font-size: 12px; }

.reply-form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
}

.hint code {
  background: #e8f0ec;
  padding: 2px 6px;
  border-radius: 6px;
  margin-right: 4px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
  animation: rise 0.2s ease;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

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

@media (max-width: 860px) {
  .stats, .grid-2, .replies-layout, .details-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { justify-content: stretch; }
  .topbar-actions .btn { flex: 1; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .panel-head input { width: 100%; }
}
