/* ═══════════════════════════════════════════════════════════════════════════
   TBClan Portal — "Obsidian Night" Dark Fantasy Theme
   Primary:   Obsidian Night  #140A26 (deep purple-black background)
   Accent:    Burnished Gold  #D4AF37 (gold headings, borders, highlights)
   Accent2:   Imperial Crimson #8B1A1A (danger, delete, enemy)
   Surface:   #1E1030          (card/panel surfaces)
   Surface2:  #271540          (hover states, table headers)
   Border:    #3D2B5E          (subtle borders)
   Text:      #E8DFE8           (primary text)
   TextMuted: #9A8AB0           (secondary text, timestamps)
   Success:   #2E7D32
   Warning:   #F57F17
   Info:      #1565C0
   Font:      Cinzel (headings), Inter (body)
═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg:          #140A26;
  --bg-alt:      #0D0619;
  --surface:     #1E1030;
  --surface2:    #271540;
  --surface3:    #2F1A4E;
  --border:      #3D2B5E;
  --border-gold: #D4AF37;
  --gold:        #D4AF37;
  --gold-light:  #F0D060;
  --gold-dim:    #A08020;
  --crimson:     #8B1A1A;
  --crimson-lt:  #C62828;
  --text:        #E8DFE8;
  --text-muted:  #9A8AB0;
  --text-dim:    #5A4A6E;
  --success:     #43A047;
  --warning:     #FB8C00;
  --info:        #1E88E5;
  --danger:      #E53935;

  /* Fonts */
  --font-heading: 'Cinzel', 'Georgia', serif;
  --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;

  /* Sizing */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --sidebar-w: 260px;
  --topbar-h:  60px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,.4);
  --shadow:     0 4px 16px rgba(0,0,0,.6);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.8);
  --shadow-gold: 0 0 20px rgba(212,175,55,.25);

  /* Transitions */
  --ease: 0.18s ease;
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); text-decoration: underline; }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbars ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-gold); }

/* ── Typography ────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--gold);
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: 0.04em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

.text-muted   { color: var(--text-muted); }
.text-gold    { color: var(--gold); }
.text-crimson { color: var(--crimson-lt); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-sm      { font-size: 0.85rem; }
.text-xs      { font-size: 0.75rem; }
.text-lg      { font-size: 1.1rem; }

/* ── Layout: Shell ─────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--ease);
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-logo img { width: 36px; height: 36px; }
.sidebar-logo-text {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.08em;
  line-height: 1.1;
}
.sidebar-logo-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 14px 12px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sidebar-nav {
  flex: 1;
  padding: 6px 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--ease);
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--text);
  background: var(--surface2);
  border-left-color: var(--gold-dim);
  text-decoration: none;
}
.nav-item.active {
  color: var(--gold);
  background: var(--surface3);
  border-left-color: var(--gold);
}
.nav-item .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.nav-badge {
  margin-left: auto;
  background: var(--crimson);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
  object-fit: cover;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}
.sidebar-user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ── Top Bar ─────────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 90;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  flex: 1;
}

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

/* ── Main Content Area ──────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  flex: 1;
  padding: 28px 28px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.stat-card:hover {
  border-color: var(--gold-dim);
  box-shadow: var(--shadow-gold);
}
.stat-icon {
  font-size: 1.8rem;
  opacity: 0.85;
}
.stat-value {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.stat-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

/* ── Grid helpers ────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all var(--ease);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #C9A227 0%, #D4AF37 60%, #E8C84A 100%);
  color: #0A0614;
  border-color: var(--gold);
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}
.btn-danger {
  background: var(--crimson);
  color: #fff;
  border-color: var(--crimson-lt);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }
.btn-icon { padding: 8px; }

/* ── Form Controls ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-control {
  width: 100%;
  padding: 9px 14px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
}
.form-control:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(212,175,55,.18);
}
.form-control::placeholder { color: var(--text-dim); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%239A8AB0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 4px; }

.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; }

/* ── Tables ───────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--ease);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text);
  vertical-align: middle;
}
.table-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 40px !important;
}

/* Sortable columns */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--gold-light); }
th.sorted-asc::after  { content: ' ↑'; color: var(--gold); }
th.sorted-desc::after { content: ' ↓'; color: var(--gold); }

/* ── Badges & Chips ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
}
.badge-gold    { background: rgba(212,175,55,.18); color: var(--gold); border: 1px solid rgba(212,175,55,.4); }
.badge-blue    { background: rgba(30,136,229,.15); color: #64B5F6; border: 1px solid rgba(30,136,229,.3); }
.badge-green   { background: rgba(67,160,71,.15);  color: #81C784; border: 1px solid rgba(67,160,71,.3); }
.badge-red     { background: rgba(229,57,53,.15);  color: #EF9A9A; border: 1px solid rgba(229,57,53,.3); }
.badge-purple  { background: rgba(156,39,176,.15); color: #CE93D8; border: 1px solid rgba(156,39,176,.3); }
.badge-gray    { background: rgba(120,120,140,.15);color: var(--text-muted); border: 1px solid var(--border); }
.badge-warning { background: rgba(251,140,0,.15);  color: #FFB74D; border: 1px solid rgba(251,140,0,.3); }

/* Role badges */
.role-leader   { background: rgba(212,175,55,.2); color: var(--gold); border: 1px solid var(--gold-dim); }
.role-superior { background: rgba(156,39,176,.2); color: #CE93D8; border: 1px solid rgba(156,39,176,.4); }
.role-officer  { background: rgba(30,136,229,.2); color: #64B5F6; border: 1px solid rgba(30,136,229,.4); }
.role-veteran  { background: rgba(67,160,71,.2);  color: #81C784; border: 1px solid rgba(67,160,71,.4); }
.role-soldier  { background: rgba(120,120,140,.2);color: var(--text-muted); border: 1px solid var(--border); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: all var(--ease);
  cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  animation: fadeSlideUp 0.2s ease;
}
.modal-lg { max-width: 780px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--gold);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px;
  transition: color var(--ease);
}
.modal-close:hover { color: var(--danger); }

/* ── Alerts / Toasts ─────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.86rem;
  margin-bottom: 14px;
}
.alert-success { background: rgba(67,160,71,.12);  border: 1px solid rgba(67,160,71,.35); color: #A5D6A7; }
.alert-error   { background: rgba(229,57,53,.12);  border: 1px solid rgba(229,57,53,.35); color: #EF9A9A; }
.alert-warning { background: rgba(251,140,0,.12);  border: 1px solid rgba(251,140,0,.35); color: #FFCC80; }
.alert-info    { background: rgba(30,136,229,.12); border: 1px solid rgba(30,136,229,.35);color: #90CAF9; }

.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  animation: slideInRight 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

/* ── Loading / Spinner ───────────────────────────────────────────────────────── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(20,10,38,.6);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ── Auth Pages ──────────────────────────────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(61,43,94,.6) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(139,26,26,.4) 0%, transparent 60%),
    var(--bg);
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo img {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  filter: drop-shadow(0 0 12px rgba(212,175,55,.5));
}
.auth-logo h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.auth-logo p {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  width: 100%;
  margin-bottom: 8px;
  transition: all var(--ease);
}
.oauth-btn:hover { border-color: var(--gold-dim); background: var(--surface3); }

/* ── Dashboard ───────────────────────────────────────────────────────────────── */
.dashboard-header {
  margin-bottom: 24px;
}
.clan-banner {
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface3) 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 22px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-gold);
  position: relative;
  overflow: hidden;
}
.clan-banner::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 100% 50%, rgba(212,175,55,.08) 0%, transparent 60%);
  pointer-events: none;
}
.clan-crest { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; }
.clan-name  { font-family: var(--font-heading); font-size: 1.4rem; font-weight: 700; color: var(--gold); }
.clan-tag   { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.clan-stats { display: flex; gap: 24px; margin-left: auto; }
.clan-stat  { text-align: center; }
.clan-stat-num   { font-family: var(--font-heading); font-size: 1.2rem; color: var(--gold); }
.clan-stat-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Leaderboard ─────────────────────────────────────────────────────────────── */
.rank-cell { display: flex; align-items: center; gap: 8px; }
.rank-medal { font-size: 1.1rem; }
.rank-num { font-family: var(--font-heading); font-size: 0.9rem; color: var(--text-muted); }

/* ── Progress Bar ────────────────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── AI Chat ─────────────────────────────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 56px);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-message {
  display: flex;
  gap: 10px;
  max-width: 80%;
}
.chat-message.user { margin-left: auto; flex-direction: row-reverse; }
.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-bubble {
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.6;
}
.chat-message.ai .chat-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
}
.chat-message.user .chat-bubble {
  background: var(--surface3);
  border: 1px solid var(--border-gold);
  border-radius: 14px 4px 14px 14px;
  color: var(--text);
}
.chat-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-muted);
}
.chat-input-bar {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.88rem;
  resize: none;
  max-height: 140px;
  outline: none;
  transition: border-color var(--ease);
}
.chat-input:focus { border-color: var(--gold-dim); }

/* AI typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Knowledge Base ──────────────────────────────────────────────────────────── */
.kb-article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  transition: border-color var(--ease), box-shadow var(--ease);
  cursor: pointer;
}
.kb-article-card:hover {
  border-color: var(--gold-dim);
  box-shadow: var(--shadow-gold);
}
.kb-article-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.kb-content {
  line-height: 1.75;
  font-size: 0.92rem;
}
.kb-content h1, .kb-content h2, .kb-content h3 { margin: 1.5em 0 0.6em; }
.kb-content p  { margin-bottom: 1em; }
.kb-content ul, .kb-content ol { margin: 0.8em 0 0.8em 1.6em; }
.kb-content li { margin-bottom: 0.4em; }
.kb-content code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  color: var(--gold-light);
}
.kb-content pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  overflow-x: auto;
  margin: 1em 0;
}
.kb-content pre code { background: none; border: none; padding: 0; }
.kb-content blockquote {
  border-left: 3px solid var(--gold-dim);
  padding: 8px 16px;
  margin: 1em 0;
  color: var(--text-muted);
  font-style: italic;
}
.kb-content mark { background: rgba(212,175,55,.25); color: var(--gold-light); padding: 0 3px; }

/* ── Events / Calendar ───────────────────────────────────────────────────────── */
.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  gap: 16px;
  transition: border-color var(--ease);
}
.event-card:hover { border-color: var(--gold-dim); }
.event-date-box {
  text-align: center;
  min-width: 52px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 6px;
}
.event-date-day  { font-family: var(--font-heading); font-size: 1.4rem; color: var(--gold); line-height: 1; }
.event-date-mon  { font-size: 0.65rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.1em; }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all var(--ease);
}
.page-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.page-btn.active { background: var(--surface3); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Empty states ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 8px; }
.empty-state p  { font-size: 0.85rem; }

/* ── Notification dot ────────────────────────────────────────────────────────── */
.notif-dot {
  width: 8px; height: 8px;
  background: var(--crimson-lt);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Tier / power colors ─────────────────────────────────────────────────────── */
.tier-1 { color: #9E9E9E; }
.tier-2 { color: #4CAF50; }
.tier-3 { color: #2196F3; }
.tier-4 { color: #9C27B0; }
.tier-5 { color: #FF9800; }
.tier-6 { color: var(--gold); text-shadow: 0 0 8px rgba(212,175,55,.6); }

/* ── Keyframes ───────────────────────────────────────────────────────────────── */
@keyframes spin          { to { transform: rotate(360deg); } }
@keyframes fadeSlideUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes typingBounce  { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes goldPulse     { 0%,100% { box-shadow: var(--shadow-gold); } 50% { box-shadow: 0 0 30px rgba(212,175,55,.5); } }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .topbar { left: 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .clan-stats { display: none; }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main-content { padding: 12px; }
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4  { padding: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
