:root {
  --bg: #f3efe7;
  --paper: #fffdf8;
  --ink: #1e1e1a;
  --muted: #6d6a61;
  --accent: #0f766e;
  --accent-soft: #d8efe9;
  --danger: #9f1239;
  --danger-soft: #fde7ef;
  --line: #ddd6c7;
  --shadow: 0 18px 40px rgba(44, 38, 28, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.14), transparent 28%),
    linear-gradient(180deg, #f7f2e7 0%, var(--bg) 100%);
  color: var(--ink);
  font: 16px/1.5 "IBM Plex Sans", "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(243, 239, 231, 0.85);
  border-bottom: 1px solid rgba(221, 214, 199, 0.8);
  padding: 16px 24px;
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.topnav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.topnav a:hover {
  color: var(--accent);
}

.topbar-logout {
  margin: 0;
}

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 24px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-head h1,
.panel-head h2,
.panel-head p { margin: 0; }

.panel-head p { color: var(--muted); }

.filters,
.actions,
.tags-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filters { margin-bottom: 20px; }

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

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

.filters input { flex: 1 1 360px; }
.filters select { flex: 0 0 220px; }

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: white;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}

button.compact {
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 14px;
  min-height: 34px;
}

.link-button.compact {
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 14px;
  min-height: 34px;
}

button.danger { background: var(--danger); }
.link-button.muted {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

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

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-actions form {
  margin: 0;
}

.table-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef7f4;
  border: 1px solid #c8e3db;
  color: #0f5b53;
  font-size: 12px;
  font-weight: 700;
}

.table-tag-empty {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

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

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

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-approved { background: var(--accent-soft); color: var(--accent); }
.badge-pending_approval,
.badge-pending_profile { background: #fff0c7; color: #8a5d00; }
.badge-rejected { background: var(--danger-soft); color: var(--danger); }
.badge-session-active { background: #dff7ea; color: #176a43; }
.badge-session-inactive { background: #ece8df; color: #6d6a61; }

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fffefb 0%, #f7f1e6 100%);
}

.status-pills,
.status-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

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

.meta-grid dt { color: var(--muted); font-size: 14px; }
.meta-grid dd {
  margin: 6px 0 0;
  font-weight: 600;
  word-break: break-word;
}

.meta-span-2 {
  grid-column: 1 / -1;
}

.wallet-list {
  display: grid;
  gap: 8px;
}

.wallet-item {
  padding: 10px 12px;
  border: 1px solid #d9e6e0;
  border-radius: 14px;
  background: #f4fbf8;
  color: #11443e;
  font: 600 14px/1.45 "IBM Plex Mono", "SFMono-Regular", monospace;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.session-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.tags-block {
  margin-top: 12px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8 0%, #f7f7ff 100%);
}

.tags-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.tags-head h2 {
  margin: 0;
}

.tags-caption {
  color: var(--muted);
  font-size: 14px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.tag-chip,
.tag-empty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #b8ddd8;
  background: #eaf8f5;
  color: #0d5f57;
  font-weight: 600;
}

.tag-chip-form {
  margin: 0;
}

.tag-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  min-width: 24px;
  border-radius: 50%;
  background: rgba(13, 95, 87, 0.12);
  color: #0d5f57;
}

.tag-add-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.tag-add-form input {
  flex: 1 1 220px;
}

.admin-message-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}


.attachment-block {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.attachment-preview {
  display: block;
  max-width: min(320px, 100%);
  max-height: 240px;
  border-radius: 14px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f3f3f3;
}

.attachment-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.attachment-link:hover {
  text-decoration: underline;
}

.broadcast-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.broadcast-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.login-panel {
  max-width: 480px;
  margin: 48px auto;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

.tag-empty {
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 75vh;
  overflow: auto;
  padding-right: 8px;
}

.chat-message {
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 14px;
  background: #fff;
}

.chat-message.dir-user { background: #f4f9ff; }
.chat-message.dir-bot { background: #f6fff9; }
.chat-message.dir-admin { background: #fff8ef; }

.chat-message header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
  color: var(--muted);
}

.chat-message pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.45 "IBM Plex Mono", "SFMono-Regular", monospace;
}

.message-rich {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-rich b {
  font-weight: 700;
}

.console-block {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.console-block summary {
  cursor: pointer;
  font-weight: 700;
}

.console-log {
  margin-top: 14px;
  max-height: 40vh;
}

details pre { margin-top: 10px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
  .status-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
