/* ═══ Auth Area (Topbar) ═══ */
.auth-area { display: flex; align-items: center; margin-left: 8px; }
.auth-login-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 8px; border: 1.5px solid var(--border-strong);
  background: var(--bg-card); color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.auth-login-btn:hover { border-color: var(--violet); color: var(--violet); background: var(--violet-soft); }

.auth-user-menu { position: relative; }
.auth-avatar-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 10px; border: 1.5px solid var(--border-strong);
  background: var(--bg-card); cursor: pointer; transition: all 0.2s;
}
.auth-avatar-btn:hover { border-color: var(--violet); }
.auth-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--orange));
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.auth-username { font-size: 13px; font-weight: 600; color: var(--text); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-plan-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  background: var(--border-strong); color: var(--text-soft);
}
.auth-plan-badge.pro { background: linear-gradient(135deg, #7c5cfc, #a78bfa); color: #fff; }
.auth-plan-badge.premium { background: linear-gradient(135deg, #f57c00, #ffb74d); color: #fff; }

/* Dropdown */
.auth-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 220px; background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  z-index: 50000; overflow: hidden; animation: authDropIn 0.15s ease;
}
.auth-dropdown.open { display: block; }
@keyframes authDropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.auth-dropdown-header { padding: 14px 16px; background: var(--bg-card); }
.auth-dropdown-name { font-size: 14px; font-weight: 700; color: var(--text); }
.auth-dropdown-email { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.auth-dropdown-divider { height: 1px; background: var(--border-strong); margin: 0; }
.auth-dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 16px; border: none; background: var(--bg-card);
  font-size: 13px; color: var(--text); cursor: pointer; transition: background 0.15s;
  font-family: inherit;
}
.auth-dropdown-item:hover { background: var(--sidebar-hover); }
.auth-dropdown-logout { color: #ef4444; }
.auth-dropdown-logout:hover { background: rgba(239,68,68,0.08); }

/* ═══ Auth Modal ═══ */
.auth-overlay {
  display: none; position: fixed; inset: 0; z-index: 90000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 20px;
}
.auth-overlay.open { display: flex; }
.auth-modal {
  position: relative; background: var(--bg-card);
  border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 40px; max-width: 440px; width: 100%;
  box-shadow: 0 25px 80px rgba(0,0,0,0.4);
  animation: authModalIn 0.25s ease;
  max-height: 90vh; overflow-y: auto;
  z-index: 90001;
}
/* Widen the modal when showing the 3-column plans view */
.auth-modal:has(#authPlansForm[style*="block"]) { max-width: 680px; }
@keyframes authModalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.auth-modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-card); border: none; color: var(--text-soft);
  cursor: pointer; padding: 4px; border-radius: 6px; transition: all 0.15s;
  z-index: 1;
}
.auth-modal-close:hover { background: var(--border-strong); color: var(--text); }
.auth-modal-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px;
}
.auth-modal-brand span { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--text); }
.auth-title { font-size: 24px; font-weight: 800; color: var(--text); margin: 0 0 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-soft); margin: 0 0 24px; }
.auth-error {
  display: none; padding: 10px 14px; border-radius: 10px;
  background: var(--rose-soft); border: 1px solid rgba(225,29,72,0.3);
  color: var(--rose); font-size: 13px; margin-bottom: 16px;
}
.auth-error.show { display: block; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.auth-field input {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1.5px solid var(--border-strong); background: var(--bg);
  color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color 0.2s; box-sizing: border-box;
}
.auth-field input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
.auth-password-wrap { position: relative; }
.auth-password-wrap input { padding-right: 40px; }
.auth-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-soft); cursor: pointer; padding: 4px;
}
.auth-submit {
  width: 100%; padding: 12px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all 0.2s; margin-top: 8px;
}
.auth-submit:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,92,252,0.3); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-switch { text-align: center; font-size: 13px; color: var(--text-soft); margin-top: 20px; }
.auth-switch a { color: var(--violet); cursor: pointer; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }
.auth-link-btn {
  display: block; width: 100%; background: none; border: none; color: var(--violet);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px 0; margin-top: 4px;
  text-align: center;
}
.auth-link-btn:hover { text-decoration: underline; }

/* ═══ OTP Input ═══ */
.otp-input-wrap {
  display: flex; gap: 10px; justify-content: center; margin: 24px 0 16px;
}
.otp-digit {
  width: 48px; height: 56px; border: 2px solid var(--border-strong); border-radius: 12px;
  background: var(--bg-card); color: var(--text); font-size: 24px; font-weight: 800;
  text-align: center; outline: none; transition: all 0.2s;
  font-family: 'Courier New', monospace;
}
.otp-digit:focus {
  border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft);
}
.otp-digit.filled { border-color: var(--violet); background: var(--violet-soft); }
.otp-digit.error { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); animation: shake 0.4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.otp-timer {
  text-align: center; font-size: 13px; color: var(--text-soft); margin-bottom: 20px;
}
.otp-timer strong { color: var(--violet); }
@media (max-width: 400px) {
  .otp-digit { width: 40px; height: 48px; font-size: 20px; }
  .otp-input-wrap { gap: 6px; }
}

/* ═══ Plans Grid ═══ */
.plans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
@media (max-width: 500px) { .plans-grid { grid-template-columns: 1fr; } }
.plan-card {
  position: relative; border: 1.5px solid var(--border-strong); border-radius: 16px;
  padding: 24px 20px; text-align: center; transition: all 0.2s;
  background: var(--bg);
}
.plan-card.plan-pro { border-color: var(--violet); background: var(--violet-soft); }
.plan-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  padding: 3px 12px; border-radius: 20px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--border-strong); color: var(--text-soft);
}
.plan-badge-pro { background: linear-gradient(135deg, var(--violet), var(--blue)); color: #fff; }
.plan-name { font-size: 18px; font-weight: 800; color: var(--text); margin: 12px 0 8px; }
.plan-price { font-size: 14px; color: var(--text-soft); margin-bottom: 16px; }
.plan-amount { font-size: 28px; font-weight: 800; color: var(--text); }
.plan-features { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; }
.plan-features li {
  position: relative; padding: 6px 0 6px 22px; font-size: 13px; color: var(--text-mid);
}
.plan-features li::before {
  content: ''; position: absolute; left: 0; top: 10px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--teal-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%230d9488' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 10px;
}
.plan-btn {
  width: 100%; padding: 10px; border-radius: 10px; border: none;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.plan-btn-current { background: var(--border-strong); color: var(--text-soft); }
.plan-btn-pro { background: linear-gradient(135deg, var(--violet), var(--blue)); color: #fff; }
.plan-btn-pro:hover { opacity: 0.9; transform: translateY(-1px); }

/* ═══ Dashboard ═══ */
.dash-content { margin-top: 20px; }
.dash-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 500px) { .dash-stat-grid { grid-template-columns: 1fr; } }
.dash-stat {
  padding: 16px; border-radius: 12px; border: 1px solid var(--border-strong);
  text-align: center; background: var(--bg);
}
.dash-stat-value { font-size: 24px; font-weight: 800; color: var(--text); }
.dash-stat-label { font-size: 11px; color: var(--text-soft); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.dash-bar-wrap { margin-top: 8px; height: 6px; border-radius: 3px; background: var(--border-strong); overflow: hidden; }
.dash-bar { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--violet), var(--blue)); transition: width 0.5s; }
.dash-bar.warn { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.dash-reset { font-size: 11px; color: var(--text-soft); margin-top: 4px; }

/* ═══ Activity Trail ═══ */
.trail-content { margin-top: 16px; max-height: 400px; overflow-y: auto; }
.trail-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.trail-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0;
  background: var(--violet);
}
.trail-dot.login { background: var(--teal); }
.trail-dot.register { background: var(--blue); }
.trail-dot.view { background: var(--violet); }
.trail-info { flex: 1; min-width: 0; }
.trail-action { font-size: 13px; font-weight: 600; color: var(--text); }
.trail-detail { font-size: 12px; color: var(--text-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trail-time { font-size: 11px; color: var(--text-soft); white-space: nowrap; }

/* ═══ Limit Modal ═══ */
.limit-overlay {
  display: none; position: fixed; inset: 0; z-index: 91000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 20px;
}
.limit-overlay.open { display: flex; }
.limit-modal {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 40px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: 0 25px 80px rgba(0,0,0,0.4);
  animation: authModalIn 0.25s ease;
  z-index: 91001;
}
.limit-icon { font-size: 48px; margin-bottom: 12px; }
.limit-title { font-size: 20px; font-weight: 800; color: var(--text); margin: 0 0 8px; }
.limit-desc { font-size: 14px; color: var(--text-soft); margin: 0 0 20px; line-height: 1.5; }
.limit-bar-wrap { height: 8px; border-radius: 4px; background: var(--border-strong); overflow: hidden; margin-bottom: 8px; }
.limit-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--orange), var(--rose)); }
.limit-count { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 20px; }
.limit-dismiss {
  display: block; width: 100%; margin-top: 12px; padding: 10px;
  background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--text-soft); font-size: 13px; cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.limit-dismiss:hover { border-color: var(--text-mid); color: var(--text-mid); }

/* ═══ Sidebar Plans Link ═══ */
.sidebar-plans-link {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: none; background: var(--violet-soft); color: var(--violet);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; margin-bottom: 8px; font-family: inherit;
}
.sidebar-plans-link:hover { background: var(--violet); color: #fff; }
.sidebar.collapsed .sidebar-plans-link span { display: none; }
.sidebar.collapsed .sidebar-plans-link { justify-content: center; padding: 8px; }

/* ═══ Home Page Plans Section ═══ */
.home-plans { max-width: 960px; margin: 0 auto 40px; }
.home-plans-grid { display: flex; flex-direction: column; gap: 12px; }
.home-plan-card {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: 14px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card); transition: all 0.2s;
}
.home-plan-card.home-plan-pro { border-color: var(--violet); background: var(--violet-soft); }
.home-plan-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; flex-shrink: 0;
}
.home-plan-info { flex: 1; min-width: 0; }
.home-plan-name { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.home-plan-badge {
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 4px;
  background: linear-gradient(135deg, var(--violet), var(--blue)); color: #fff;
}
.home-plan-desc { font-size: 12px; color: var(--text-soft); margin-top: 3px; line-height: 1.4; }
.home-plan-price { font-size: 22px; font-weight: 800; color: var(--text); flex-shrink: 0; }
.home-plan-price small { font-size: 12px; font-weight: 500; color: var(--text-soft); }

@media (max-width: 520px) {
  .home-plan-card { flex-wrap: wrap; gap: 10px; }
  .home-plan-price { width: 100%; text-align: right; }
}

/* ═══ Mobile Auth ═══ */
@media (max-width: 768px) {
  .auth-username { display: none; }
  .auth-modal { padding: 28px 20px; margin: 10px; border-radius: 16px; }
  .auth-title { font-size: 20px; }
  .plans-grid { grid-template-columns: 1fr; }
  .auth-login-btn span { display: none; }
  .auth-login-btn { padding: 6px 10px; }
}
