:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1e1e1e;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-dim: #888;
  --accent: #e1306c;
  --accent-2: #833ab4;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --orange: #f97316;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Login ─── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
}

.login-box h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
  outline: none;
  margin-bottom: 16px;
}
.login-box input:focus { border-color: var(--accent); }

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--red);
  min-height: 20px;
}

/* ─── Header ─── */
.header {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: white;
  text-decoration: none;
}

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

.tz-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}
.status-dot.checking { background: var(--orange); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.status-text {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}

/* ─── Buttons ─── */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: white;
  color: var(--accent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: white;
}
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-ghost-dark {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost-dark:hover { border-color: var(--text-dim); }
.btn-primary-dark {
  background: var(--accent);
  color: white;
}
.btn-primary-dark:hover { background: #c9285f; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── Layout ─── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ─── Setup Banner ─── */
.setup-banner {
  background: linear-gradient(135deg, #f97316, #ef4444);
  padding: 12px 20px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: white;
}

/* ─── List Toolbar ─── */
.list-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.period-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 8px;
  flex-shrink: 0;
}

.period-tab {
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.period-tab.active {
  background: var(--accent);
  color: white;
}
.period-tab:hover:not(.active) { color: var(--text); }

/* ─── Add Profile ─── */
.add-form {
  display: flex;
  gap: 8px;
  flex: 1;
}

.add-form input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.add-form input:focus { border-color: var(--accent); }
.add-form input::placeholder { color: var(--text-dim); }

/* ─── Profile List (rows) ─── */
.profiles-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-row {
  display: grid;
  grid-template-columns: 44px 1fr repeat(3, 120px) 140px 36px;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.profile-row:hover {
  border-color: var(--accent);
  background: #181818;
}

.profile-row-pic {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 2px solid var(--border);
}

.profile-row-info {
  min-width: 0;
}
.profile-row-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.profile-row-username {
  font-size: 12px;
  color: var(--text-dim);
}

.profile-row-metric {
  text-align: right;
}
.profile-row-metric-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.profile-row-metric-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.profile-row-metric-change {
  font-size: 11px;
  font-weight: 500;
}
.profile-row-metric-change.up { color: var(--green); }
.profile-row-metric-change.down { color: var(--red); }
.profile-row-metric-change.neutral { color: var(--text-dim); }

.profile-row-time {
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

.badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.badge-private {
  background: rgba(239,68,68,0.15);
  color: var(--red);
}
.badge-public {
  background: rgba(34,197,94,0.15);
  color: var(--green);
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 6px;
  opacity: 0;
  transition: 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-row:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* ─── List header row ─── */
.profiles-list-header {
  display: grid;
  grid-template-columns: 44px 1fr repeat(3, 120px) 140px 36px;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.profiles-list-header span:nth-child(n+3):nth-child(-n+5) { text-align: right; }
.profiles-list-header span:nth-child(6) { text-align: right; }

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════
   DETAIL PAGE
   ═══════════════════════════════════════════════════════════════ */

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 20px;
  transition: 0.15s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Detail Header ─── */
.detail-profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.detail-pic {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 3px solid var(--border);
  flex-shrink: 0;
}

.detail-info {
  flex: 1;
  min-width: 0;
}
.detail-display-name {
  font-size: 20px;
  font-weight: 700;
}
.detail-username {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ─── Detail Stats Cards ─── */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.stat-card-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.stat-card-posts .stat-card-value { color: var(--green); }
.stat-card-followers .stat-card-value { color: var(--accent); }
.stat-card-following .stat-card-value { color: var(--blue); }

/* ─── Detail Main Tabs ─── */
.detail-main-tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.detail-main-tab {
  flex: 1;
  padding: 14px 16px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  position: relative;
}
.detail-main-tab.active {
  color: var(--accent);
  background: rgba(225,48,108,0.08);
}
.detail-main-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}
.detail-main-tab:hover:not(.active) { color: var(--text); background: var(--surface-2); }

.detail-tab-content { min-height: 200px; }

.tab-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 14px;
}
.tab-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ─── Posts Grid ─── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}
.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.post-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface-2);
  overflow: hidden;
}
.post-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.post-card-img.no-img {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 32px;
}

.post-type-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
}

.post-card-body {
  padding: 14px;
}

.post-card-stats {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
}
.post-stat {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}
.post-stat-icon {
  font-size: 12px;
  color: var(--text-dim);
}

.post-card-caption {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-date {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.7;
}

/* ─── Users List (Followers/Following) ─── */
.users-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: 0.15s;
}
.user-card:hover {
  border-color: var(--accent);
  background: #181818;
}

.user-card-pic {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.user-card-info { min-width: 0; }
.user-card-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-card-username {
  font-size: 12px;
  color: var(--text-dim);
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  font-size: 9px;
  flex-shrink: 0;
}

/* ─── Controls ─── */
.detail-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.view-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 8px;
}

.view-tab {
  padding: 7px 18px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s;
}
.view-tab.active {
  background: var(--accent);
  color: white;
}
.view-tab:hover:not(.active) { color: var(--text); }

.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-nav button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
}
.date-nav button:hover { border-color: var(--accent); }

.date-nav input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
}

/* ─── Chart ─── */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  height: 320px;
  position: relative;
  margin-bottom: 16px;
}

/* ─── Data Table ─── */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table thead th {
  background: var(--surface-2);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.data-table thead th:first-child { border-radius: 12px 0 0 0; }
.data-table thead th:last-child { border-radius: 0 12px 0 0; }

.data-table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(225,48,108,0.04); }

.change { font-size: 11px; font-weight: 500; margin-left: 6px; }
.change.up { color: var(--green); }
.change.down { color: var(--red); }
.change.neutral { color: var(--text-dim); }

/* ─── Settings Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay.visible { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
}
.modal h2 { font-size: 16px; margin-bottom: 16px; }
.modal-desc { font-size: 13px; color: var(--text); margin-bottom: 14px; line-height: 1.5; }
.modal-help {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
}
.modal-help strong { color: var(--text); }
.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.modal input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 12px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ─── Toasts ─── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { background: var(--green); color: white; }
.toast.error { background: var(--red); color: white; }
.toast.info { background: var(--blue); color: white; }

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .profile-row {
    grid-template-columns: 40px 1fr repeat(3, 80px) 36px;
    gap: 10px;
    padding: 12px 14px;
  }
  .profile-row-time { display: none; }
  .profiles-list-header {
    grid-template-columns: 40px 1fr repeat(3, 80px) 36px;
    gap: 10px;
    padding: 8px 14px;
  }
  .profiles-list-header span:nth-child(6) { display: none; }
  .profile-row-metric-value { font-size: 14px; }
}

@media (max-width: 640px) {
  .header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .container { padding: 16px; }
  .list-toolbar { flex-direction: column; }
  .detail-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 14px 10px; }
  .stat-card-value { font-size: 22px; }
  .detail-controls { flex-direction: column; align-items: stretch; }
  .profile-row {
    grid-template-columns: 36px 1fr 70px 70px 70px 30px;
    gap: 6px;
    padding: 10px 12px;
  }
  .profiles-list-header {
    grid-template-columns: 36px 1fr 70px 70px 70px 30px;
    gap: 6px;
    padding: 6px 12px;
  }
}
