/* ===== Design tokens ===== */
:root {
  --bg: #0b0d12;
  --bg-elevated: #10131b;
  --bg-card: #141822;
  --bg-input: #0f1219;
  --border: #232838;
  --border-soft: #1b202e;
  --text: #e6e8ee;
  --text-muted: #8b93a7;
  --text-faint: #5b637a;

  --accent: #ff6a2b;
  --accent-2: #ff9142;
  --accent-soft: rgba(255, 106, 43, 0.14);
  --accent-border: rgba(255, 106, 43, 0.35);

  --danger: #ff5a5f;
  --danger-soft: rgba(255, 90, 95, 0.12);
  --success: #3ecf8e;

  --blue: #5b9dff;
  --purple: #b98bff;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);

  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }

::selection { background: var(--accent-soft); }

/* ===== App shell / layout ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.4rem 1.2rem;
  border-bottom: 1px solid var(--border-soft);
}
.brand-flame {
  display: inline-block;
  width: 24px !important;
  height: auto !important;
  max-width: 24px !important;
  object-fit: contain;
  vertical-align: middle;
}
.brand-text { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.brand-text small { color: var(--text-muted); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.02em; }

.nav-links {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.15rem;
}
.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.nav-links a:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }
.nav-links a.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-links .icon { font-size: 1.05rem; }

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.2rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.session-pill {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}

.content {
  padding: 1.75rem;
  flex: 1;
}

/* ===== Cards / grids ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  gap: 0.75rem;
}
.card-header h2 { font-size: 1rem; margin: 0; }
.muted-note { color: var(--text-faint); font-size: 0.8rem; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.stat-icon {
  font-size: 1.6rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.82rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-card); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a0e08; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; margin-top: 0.9rem; }

/* ===== Forms / filter bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: end;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
}
.filter-group { display: flex; flex-direction: column; gap: 0.35rem; min-width: 150px; }
.filter-group.grow { flex: 1; min-width: 200px; }
.filter-actions { flex-direction: row; align-self: end; }
.filter-group label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

input[type="text"], input[type="password"], input[type="datetime-local"], select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent-border); }
.input-group { display: flex; gap: 0.4rem; }
.input-group .match-mode { flex-shrink: 0; max-width: 155px; }
.input-group input { flex: 1; min-width: 0; }

.input-with-toggle { position: relative; margin-bottom: 1rem; }
.input-with-toggle input { width: 100%; padding-right: 2.5rem; }
.toggle-visibility {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
}

/* ===== Alerts ===== */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  font-size: 0.88rem;
}
.alert-error { background: var(--danger-soft); color: #ffb3b5; border: 1px solid rgba(255, 90, 95, 0.35); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.log-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border-soft);
}
.log-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.log-row { cursor: pointer; }
.log-row:hover td { background: var(--bg-elevated); }
.col-time { white-space: nowrap; color: var(--text-muted); }
.col-message { max-width: 480px; overflow-wrap: anywhere; }
.col-sender .arrow { color: var(--text-faint); margin: 0 0.15rem; }

.empty-state { color: var(--text-faint); text-align: center; padding: 1.5rem 0; font-size: 0.88rem; }

.load-more-wrap { display: flex; justify-content: center; padding-top: 1rem; }

/* ===== Badges / tags ===== */
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-public { background: rgba(91, 157, 255, 0.14); color: var(--blue); }
.badge-private { background: rgba(185, 139, 255, 0.14); color: var(--purple); }
.badge-staff { background: var(--accent-soft); color: var(--accent-2); }
.badge-other { background: rgba(139, 147, 167, 0.14); color: var(--text-muted); }

.tag {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.tag:hover { color: var(--text); text-decoration: none; border-color: var(--accent-border); }
.tag-sm { font-size: 0.72rem; padding: 0.15rem 0.5rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.quick-links { display: flex; flex-direction: column; gap: 0.5rem; }
.quick-link {
  display: block;
  padding: 0.6rem 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}
.quick-link:hover { border-color: var(--accent-border); text-decoration: none; }

/* ===== Player card ===== */
.player-card { margin-bottom: 1.25rem; }
.player-identity { display: flex; align-items: center; gap: 1rem; }
.player-avatar {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.player-identity h2 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.uuid-pill { color: var(--text-muted); font-size: 0.78rem; }

/* ===== Chat bubbles (conversation view) ===== */
.thread { display: flex; flex-direction: column; gap: 0.6rem; max-height: 65vh; overflow-y: auto; padding: 0.25rem; }
.bubble-row { display: flex; }
.bubble-row.from-a { justify-content: flex-end; }
.bubble-row.from-b { justify-content: flex-start; }
.bubble {
  max-width: 65%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 0.55rem 0.8rem;
}
.bubble-row.from-a .bubble { background: var(--accent-soft); border-color: var(--accent-border); }
.bubble-meta { display: flex; gap: 0.5rem; font-size: 0.72rem; color: var(--text-faint); margin-bottom: 0.2rem; }
.bubble-sender { font-weight: 700; color: var(--text-muted); }
.bubble-text { font-size: 0.9rem; overflow-wrap: anywhere; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 0.75rem; right: 0.85rem;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.3rem; cursor: pointer; line-height: 1;
}
.modal h3 { margin: 0 0 1rem; font-size: 1rem; }
.detail-list { display: grid; grid-template-columns: 100px 1fr; gap: 0.5rem 0.75rem; margin: 0; }
.detail-list dt { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; }
.detail-list dd { margin: 0; font-size: 0.88rem; overflow-wrap: anywhere; }

/* ===== Login page ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1a1410 0%, var(--bg) 55%);
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .brand-flame {
  display: block;
  width: 128px !important;
  height: auto !important;
  max-width: 128px !important;
  margin: 0 auto 0.4rem;
  object-fit: contain;
}
.login-brand h1 { margin: 0; font-size: 1.3rem; }
.login-brand p { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.85rem; }
.login-card label { display: block; font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.4rem; }
.login-hint { color: var(--text-faint); font-size: 0.76rem; text-align: center; margin: 1.1rem 0 0; line-height: 1.5; }

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .hamburger { display: block; }
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 40;
    transition: left 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { left: 0; }
  .content { padding: 1.1rem; }
  .topbar { padding: 0.9rem 1.1rem; }
  .filter-bar { padding: 0.9rem; }
  .col-message { max-width: 220px; }
}
