@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Sans:wght@300;400;500;600;700&family=Syne:wght@700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f4f6fb;
  --white:      #ffffff;
  --sidebar-bg: #0f1117;
  --sidebar-w:  220px;
  --primary:    #6366f1;
  --primary-dk: #4f46e5;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #06b6d4;
  --text:       #111827;
  --text-2:     #6b7280;
  --text-3:     #9ca3af;
  --border:     #e8eaf2;
  --shadow:     0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

html { font-size: 14px; }
body { font-family: 'Ubuntu Sans', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: 'Ubuntu Sans', sans-serif; }
input, select, textarea { font-family: 'Ubuntu Sans', sans-serif; }

/* ── Layout ──────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; height: 100vh;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.04);
}

/* Logo */
.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-mark {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 13px; font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.logo-nebo {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.08em;
}
.logo-fanbase {
  font-family: 'Syne', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.18em;
  margin-top: 2px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  border-radius: 8px;
  transition: all 0.15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.06); }
.nav-link.active { color: #fff; background: var(--primary); }
.nav-link.active svg { opacity: 1; }

/* Footer */
.sidebar-footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.footer-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; margin-bottom: 8px;
}
.footer-avatar {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.footer-info { min-width: 0; }
.footer-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-role { font-size: 11px; color: rgba(255,255,255,0.3); }
.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.35);
  padding: 7px 12px;
  font-size: 12px; font-weight: 500;
  font-family: 'Ubuntu Sans', sans-serif;
  border-radius: 7px;
  text-align: center;
  transition: all 0.15s;
}
.btn-logout:hover { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.7); }

/* ── Main ────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-2); }

.content { padding: 26px; flex: 1; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 18px; }

/* ── Stats ───────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 14px; margin-bottom: 22px; }

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
}
.stat-card:nth-child(1)::after { background: #6366f1; }
.stat-card:nth-child(2)::after { background: #22c55e; }
.stat-card:nth-child(3)::after { background: #f59e0b; }
.stat-card:nth-child(4)::after { background: #ef4444; }
.stat-card:nth-child(5)::after { background: #06b6d4; }

.stat-label { font-size: 11px; font-weight: 500; color: var(--text-3); margin-bottom: 8px; letter-spacing: 0.02em; }
.stat-value {
  font-family: 'Ubuntu Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-value.sm { font-size: 20px; }

/* ── Charts ──────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 22px; }

/* ── Table ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
  padding: 10px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--white); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f4f5fa; transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8f9ff; }
tbody td { padding: 12px 16px; vertical-align: middle; }
.td-name { font-weight: 600; font-size: 14px; }
.td-sub  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Tags ────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 2px 9px; font-size: 11px; font-weight: 600; border-radius: 20px; background: #eff0ff; color: #6366f1; }
.tag.green  { background: #f0fdf4; color: #16a34a; }
.tag.orange { background: #fffbeb; color: #d97706; }
.tag.red    { background: #fef2f2; color: #dc2626; }
.tag.cyan   { background: #ecfeff; color: #0891b2; }

/* ── Filters ─────────────────────────────────────── */
.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 16px 20px; background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow);
}
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.filter-input, .filter-select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-size: 13px; color: var(--text);
  background: var(--white); outline: none; min-width: 140px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-input:focus, .filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }

/* ── Buttons ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; font-size: 13px; font-weight: 600; font-family: 'Ubuntu Sans', sans-serif; border: none; border-radius: 8px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); box-shadow: 0 3px 10px rgba(99,102,241,0.3); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f5f5ff; }
.btn-danger  { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: #fff5f5; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Pagination ──────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--white); border-radius: 0 0 12px 12px; }
.page-info { margin-left: auto; color: var(--text-3); font-size: 12px; }
.page-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 7px; background: var(--white); font-size: 13px; cursor: pointer; transition: all 0.1s; color: var(--text-2); font-family: 'Ubuntu Sans', sans-serif; }
.page-btn:hover  { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Fan header ──────────────────────────────────── */
.fan-header {
  display: flex; align-items: flex-start; gap: 18px;
  padding: 26px 28px;
  background: linear-gradient(135deg, #0f1117 0%, #1e2240 100%);
  color: #fff; border-radius: 12px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.fan-avatar { width: 56px; height: 56px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.fan-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.fan-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: rgba(255,255,255,0.5); }

.fan-stats-bar { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 20px; }
.fan-stat { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; box-shadow: var(--shadow); }
.fan-stat .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 8px; }
.fan-stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; }

/* ── Export ──────────────────────────────────────── */
.export-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; margin-bottom: 22px; }
.export-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); transition: border-color 0.15s; }
.export-card:hover { border-color: var(--primary); }
.export-platform { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.export-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; margin-bottom: 12px; }
.export-desc { font-size: 13px; color: var(--text-2); margin-bottom: 12px; line-height: 1.6; }
.export-fields { font-size: 11px; color: var(--text-3); padding: 8px 12px; background: var(--bg); border-radius: 6px; margin-bottom: 16px; font-family: monospace; }

/* ── Segment builder ─────────────────────────────── */
.segment-builder { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 22px; }
.segment-row { display: grid; grid-template-columns: repeat(4,1fr) auto; gap: 10px; align-items: flex-end; }
.segment-preview { margin-top: 14px; padding: 13px 16px; background: #f0f0ff; border: 1px solid #d4d6ff; border-radius: 8px; font-size: 14px; color: var(--text-2); }
.segment-count { font-size: 26px; font-weight: 700; color: var(--primary); }

/* ── Login ───────────────────────────────────────── */
.login-page { min-height: 100vh; background: #0f1117; display: flex; align-items: center; justify-content: center; }
.login-box { width: 380px; background: var(--white); border-radius: 14px; padding: 38px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.login-logo { margin-bottom: 28px; display: flex; align-items: center; gap: 12px; }
.login-logo .logo-mark { width: 38px; height: 38px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 800; color: #fff; }
.login-logo .logo-text { display: flex; flex-direction: column; line-height: 1; }
.login-logo .logo-nebo { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 800; letter-spacing: 0.06em; }
.login-logo .logo-fanbase { font-family: 'Syne', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 0.2em; color: var(--text-3); margin-top: 2px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); margin-bottom: 6px; }
.form-input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 13px; font-size: 14px; font-family: 'Ubuntu Sans', sans-serif; color: var(--text); background: var(--white); outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.btn-login { width: 100%; background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 12px; font-family: 'Ubuntu Sans', sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 8px; transition: all 0.15s; }
.btn-login:hover { background: var(--primary-dk); box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
.btn-login:disabled { opacity: 0.55; cursor: default; box-shadow: none; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; padding: 10px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: none; }

/* ── Toast ───────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 11px 18px; font-size: 13px; font-weight: 500; border-radius: 10px; z-index: 1000; transform: translateY(70px); opacity: 0; transition: all 0.25s cubic-bezier(.34,1.56,.64,1); box-shadow: 0 6px 20px rgba(0,0,0,0.2); pointer-events: none; }
.toast.show    { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── Loading ─────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text-3); font-size: 13px; gap: 10px; }
.spinner { width: 17px; height: 17px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.65s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 56px 24px; color: var(--text-3); font-size: 13px; }
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
tbody tr:hover .row-actions { opacity: 1; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); margin-bottom: 18px; font-weight: 500; transition: color 0.15s; }
.back-link:hover { color: var(--primary); }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--white); border-radius: 14px; padding: 30px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; }