:root{
  --bg:#f5f6fa;
  --card:#ffffff;
  --text:#1f2937;
  --muted:#6b7280;
  --line:#e5e7eb;
  --primary:#3b82f6;

  --sidebar:#0f172a;
  --sidebar-2:#111c33;
  --sidebar-text:#cbd5e1;
  --sidebar-active:#1e3a8a;
}

*{box-sizing:border-box;}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue";
}

.layout{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width:260px;
  background:linear-gradient(180deg,var(--sidebar),var(--sidebar-2));
  color:var(--sidebar-text);
  display:flex;
  flex-direction:column;
  padding:16px 14px;
  transition: width .2s ease;
  position:sticky;
  top:0;
  height:100vh;
}

.layout.collapsed .sidebar{
  width:86px;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px 16px;
  border-bottom:1px solid rgba(255,255,255,.08);
  margin-bottom:10px;
}
.brand-mark{display:flex; gap:6px; align-items:center;}
.dot{width:10px;height:10px;border-radius:50%;}
.dot-1{background:#60a5fa;}
.dot-2{background:#34d399;}
.dot-3{background:#f59e0b;}
.brand-name{
  font-weight:700;
  font-size:18px;
  letter-spacing:.2px;
}
.layout.collapsed .brand-name{display:none;}

.nav{display:flex; flex-direction:column; gap:6px; padding:10px 6px;}
.nav-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  border-radius:12px;
  text-decoration:none;
  color:var(--sidebar-text);
  opacity:.92;
}
.nav-item i{font-size:20px; min-width:22px;}
.nav-item span{font-weight:600;}
.nav-item:hover{background:rgba(255,255,255,.06);}
.nav-item.active{
  background:rgba(59,130,246,.22);
  border:1px solid rgba(59,130,246,.22);
}

.layout.collapsed .nav-item span{display:none;}
.layout.collapsed .nav-item{justify-content:center;}

.sidebar-footer{
  margin-top:auto;
  padding:10px 6px 6px;
  display:flex;
  align-items:center;
  gap:8px;
}
.collapse-btn{
  margin-left:auto;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  color:var(--sidebar-text);
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
}
.layout.collapsed .collapse-btn i{transform:rotate(180deg);}

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

.topbar{
  height:64px;
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 18px;
  background:#fff;
  border-bottom:1px solid var(--line);
  position:sticky;
  top:0;
  z-index:10;
}

.icon-btn{
  width:44px;height:44px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.icon-btn i{font-size:22px; color:#374151;}
.topbar-title{
  font-size:28px;
  font-weight:800;
  letter-spacing:-.4px;
}
.topbar-right{margin-left:auto;}
.user-pill{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
}
.avatar{width:22px;height:22px;border-radius:50%; background:#d1d5db;}
.user-name{font-weight:700; color:#374151; font-size:14px;}

.content{padding:22px 22px 40px;}

.page-head{margin-bottom:14px;}
.h1{margin:0; font-size:34px; font-weight:900; letter-spacing:-.6px;}
.muted{margin:6px 0 0; color:var(--muted);}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.filters{margin:14px 0 18px;}
.filters-row{display:flex; gap:14px; flex-wrap:wrap; align-items:end;}
.field label{display:block; font-weight:800; font-size:12px; color:#374151; margin-bottom:6px;}
.field select{
  min-width:220px;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-weight:700;
  outline:none;
}

.grid-2{
  display:grid;
  grid-template-columns: 1fr 1.35fr;  /* left, right */
  gap:16px;
  align-items:start;
}

/* Responsive */
@media (max-width: 1100px){
  .grid-2{ grid-template-columns: 1fr; }
  .right-panel .sticky{ position: static; }
}

.topic-card{margin-bottom:14px;}
.topic-head{display:flex; align-items:center; gap:10px; margin-bottom:10px;}
.badge{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:10px;
  background:#eef2ff;
  color:#1e3a8a;
  font-weight:800;
  font-size:12px;
}
.badge.sm{padding:5px 9px; font-size:12px;}
.topic-title{font-size:22px; font-weight:900; letter-spacing:-.3px;}
.topic-meta{color:#111827; display:flex; flex-direction:column; gap:8px;}
.linkish{color:#1d4ed8; font-weight:700;}

.right-panel .sticky{position:sticky; top:86px;}
.panel-title{font-size:22px; font-weight:900; margin-bottom:10px;}
.panel-subtitle{font-weight:900; margin:10px 0 8px;}
.mini-card{
  border-top:1px solid var(--line);
  padding-top:12px;
  margin-top:12px;
}
.mini-head{display:flex; align-items:center; gap:10px; margin-bottom:8px;}
.mini-title{font-size:18px; font-weight:900;}
.mini-meta{display:flex; flex-direction:column; gap:6px; color:#111827;}

.divider{height:1px; background:var(--line); margin:14px 0;}
.content-box{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fbfbfd;
}
.pre{
  margin:0;
  white-space:pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:13px;
  color:#111827;
}

.topic-link{
  text-decoration:none;
  color:inherit;
  display:block;
}

.topic-card.selected{
  border:2px solid rgba(59,130,246,.55);
  box-shadow: 0 12px 40px rgba(59,130,246,0.10);
}

.badge-verified{
  background:#ecfdf5;
  color:#065f46;
  border:1px solid rgba(6,95,70,.15);
  margin-left:auto;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  cursor:pointer;
  font-weight:800;
  background:#fff;
}

.btn-primary{
  background: var(--primary);
  border-color: rgba(59,130,246,.35);
  color:#fff;
}

.btn-light{
  background:#fff;
  border-color: var(--line);
  color:#111827;
}

.btn-danger{
  background:#fee2e2;
  border-color:#fecaca;
  color:#7f1d1d;
}

.form-grid{display:flex; flex-direction:column; gap:12px;}
.form-field label{display:block; font-weight:900; font-size:12px; color:#374151; margin-bottom:6px;}

.input{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-weight:600;
  outline:none;
}

.textarea{font-weight:600; line-height:1.35;}
.select-multi{min-height:160px;}

.actions-row{
  margin-top:14px;
  display:flex;
  align-items:center;
  gap:12px;
}

.pill{
  display:inline-flex;
  align-items:center;
  padding:4px 8px;
  border-radius:999px;
  background:#f1f5f9;
  border:1px solid #e2e8f0;
  font-weight:800;
  font-size:12px;
  margin-right:6px;
}

.form-grid{display:flex; flex-direction:column; gap:12px;}
.form-field label{display:block; font-weight:900; font-size:12px; color:#374151; margin-bottom:6px;}
.input{width:100%; padding:12px; border-radius:12px; border:1px solid var(--line); background:#fff; font-weight:600;}
.textarea{font-weight:600; line-height:1.35;}
.actions-row{margin-top:14px; display:flex; align-items:center; gap:12px;}

.table{width:100%; border-collapse:collapse;}
.table th,.table td{padding:12px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top;}
.table thead th{font-size:12px; color:#6b7280; font-weight:900; background:#fafafa;}

.status{display:inline-flex; padding:6px 10px; border-radius:999px; font-weight:900; font-size:12px;}
.status.ok{background:#ecfdf5; border:1px solid #a7f3d0; color:#065f46;}
.status.warn{background:#fffbeb; border:1px solid #fde68a; color:#92400e;}

.pill{
  display:inline-flex; align-items:center;
  padding:4px 8px; border-radius:999px;
  background:#f1f5f9; border:1px solid #e2e8f0;
  font-weight:800; font-size:12px; margin-right:6px;
}

.progress-wrap{
  width: 140px;
  height: 10px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar{
  height: 100%;
  border-radius: 999px;
  background: #3b82f6;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.profile-wrapper{
  max-width:1100px;
}

.profile-grid{
  display:grid;
  grid-template-columns:320px 1fr;
  gap:30px;
}

/* LEFT PROFILE CARD */

.profile-card{
  background:white;
  border-radius:16px;
  padding:30px;
  text-align:center;
  border:1px solid #e5e7eb;
}

.profile-avatar{
  width:90px;
  height:90px;
  border-radius:50%;
  background:#f1f5f9;
  margin:auto;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:40px;
  margin-bottom:15px;
}

.profile-avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:50%;
}

.profile-email{
  color:#64748b;
  font-size:14px;
}

.profile-tags{
  margin-top:15px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.profile-tags span{
  font-size:14px;
  color:#334155;
}

.profile-links{
  margin-top:20px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.profile-links a{
  font-size:14px;
  color:#2563eb;
}

/* RIGHT FORM CARD */

.profile-form-card{
  background:white;
  padding:30px;
  border-radius:16px;
  border:1px solid #e5e7eb;
}

.profile-form-card h3{
  margin:0;
}

.profile-subtitle{
  color:#64748b;
  margin-bottom:20px;
}

.form-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
}

.form-group{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:16px;
}

.form-group input{
  padding:10px;
  border-radius:8px;
  border:1px solid #d1d5db;
}

.btn-save{
  margin-top:10px;
  background:#2563eb;
  color:white;
  padding:10px 18px;
  border:none;
  border-radius:8px;
  cursor:pointer;
}

/* Loader + toasts */
.ai-loader{position:fixed;inset:0;background:rgba(15,23,42,.38);backdrop-filter:blur(8px);display:flex;align-items:center;justify-content:center;z-index:9999;}
.ai-loader.hidden{display:none;}
.ai-loader-content{min-width:300px;max-width:420px;padding:28px 24px;border-radius:24px;background:rgba(255,255,255,.88);border:1px solid rgba(255,255,255,.6);box-shadow:0 25px 80px rgba(15,23,42,.22);text-align:center;}
.loader-dots{display:flex;justify-content:center;gap:10px;margin-bottom:12px;}
.loader-dots .dot{width:14px;height:14px;border-radius:50%;display:inline-block;animation:dotBounce 1s infinite ease-in-out;}
.loader-dots .green{background:#34d399;animation-delay:0s;}
.loader-dots .yellow{background:#f59e0b;animation-delay:.16s;}
.loader-dots .red{background:#ef4444;animation-delay:.32s;}
@keyframes dotBounce{0%,80%,100%{transform:translateY(0);opacity:.55;}40%{transform:translateY(-9px);opacity:1;}}
.loader-title{font-size:20px;font-weight:900;color:#0f172a;}
.loader-text{margin-top:6px;color:#475569;font-weight:600;}
.loader-progress{height:10px;background:#e2e8f0;border-radius:999px;overflow:hidden;margin-top:16px;}
.loader-progress span{display:block;height:100%;width:38%;background:linear-gradient(90deg,#2563eb,#7c3aed);border-radius:999px;animation:loaderSlide 1.2s infinite ease-in-out;}
@keyframes loaderSlide{0%{transform:translateX(-120%);}50%{transform:translateX(140%);}100%{transform:translateX(320%);}}
.toast-container{position:fixed;top:84px;right:18px;display:grid;gap:10px;z-index:10001;max-width:360px;}
.toast{padding:14px 16px;border-radius:16px;color:#fff;box-shadow:0 18px 40px rgba(15,23,42,.18);display:flex;align-items:flex-start;gap:10px;animation:toastIn .25s ease;}
.toast.info{background:#2563eb;}
.toast.success{background:#16a34a;}
.toast.error{background:#dc2626;}
.toast.warning{background:#d97706;}
.toast .toast-body{font-weight:700;line-height:1.45;}
.toast .toast-close{margin-left:auto;background:none;border:none;color:#fff;font-size:18px;cursor:pointer;opacity:.85;}
@keyframes toastIn{from{opacity:0;transform:translateY(-8px) scale(.98);}to{opacity:1;transform:translateY(0) scale(1);}}
.upgrade-modal{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;justify-content:center;}
.upgrade-modal.hidden{display:none;}
.upgrade-modal__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.36);backdrop-filter:blur(6px);}
.upgrade-modal__card{position:relative;background:#fff;border:1px solid var(--line);border-radius:22px;padding:24px;max-width:460px;width:calc(100% - 32px);box-shadow:0 30px 80px rgba(15,23,42,.22);}

.logo-dots .dot{
  animation:logoPulse 3s infinite ease-in-out;
}

.dot.green{ animation-delay:0s }
.dot.yellow{ animation-delay:.2s }
.dot.red{ animation-delay:.4s }

@keyframes logoPulse{
  0%,100%{
    transform:scale(1);
    opacity:.8;
  }
  50%{
    transform:scale(1.15);
    opacity:1;
  }
}