:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: rgba(17,24,39,.65);
  --border: rgba(17,24,39,.10);
  --shadow: 0 8px 22px rgba(17,24,39,.06);
  --radius: 14px;
  --primary: #4f46e5; /* indigo-ish */
  --primary-2: #4338ca;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

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

/* --- sidebar --- */
.sidebar{
  width: 270px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar-top{
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.brand-row{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 12px;
}

.brand-badge{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
}

.brand-name{
  font-weight: 800;
  font-size: 15px;
  line-height: 1.1;
}
.brand-subtitle{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px;
}

.nav-item{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: background .15s ease;
}

.nav-item:hover{ background: rgba(17,24,39,.04); }
.nav-item.active{ background: rgba(79,70,229,.12); }

.nav-icon{
  width: 18px;
  display: inline-flex;
  justify-content: center;
}

/* --- sidebar bottom user card --- */
.sidebar-bottom{
  padding: 10px 6px 0;
}

.user-card{
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 10px 20px rgba(17,24,39,.05);
}

.user-left{
  display:flex;
  align-items:center;
  gap:10px;
}

.user-avatar{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f3f4f6;
}

.user-avatar-fallback{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #e5e7eb;
  border: 1px solid var(--border);
}

.user-meta{ min-width: 0; }
.user-name{
  font-weight: 700;
  font-size: 13px;
  line-height: 1.1;
}
.user-email{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.logout-btn{
  display:block;
  margin-top: 10px;
  text-align:center;
  padding: 10px 12px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  text-decoration:none;
  font-weight: 700;
}

.logout-btn:hover{ background: #0b1220; }

/* --- main --- */
.main{
  flex: 1;
  padding: 22px 26px;
}

/* --- page header --- */
.page-header{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.page-title{
  font-size: 20px;
  font-weight: 800;
  margin: 0;
}

.page-subtitle{
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.header-actions{
  display:flex;
  gap: 10px;
}

.pill{
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration:none;
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
}

.pill:hover{ background: rgba(17,24,39,.04); }

/* --- hero panel like old dashboard --- */
.hero{
  background: linear-gradient(0deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-kicker{
  font-size: 12px;
  opacity: .9;
  margin-bottom: 4px;
}

.hero-title{
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 12px 0;
}

.module-grid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.module-card{
  background: rgba(255,255,255,.96);
  color: var(--text);
  border-radius: 14px;
  padding: 14px;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.65);
}

.module-top{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  margin-bottom: 6px;
}

.module-title{
  margin: 0;
  font-weight: 800;
  font-size: 13px;
  display:flex;
  align-items:center;
  gap: 8px;
}

.module-tag{
  font-size: 10px;
  font-weight: 800;
  color: rgba(17,24,39,.7);
}

.module-desc{
  margin: 0;
  font-size: 12px;
  color: rgba(17,24,39,.7);
}

.module-desc.muted{ color: var(--muted); }

/* --- lower panels row --- */
.row{
  display:grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 20px rgba(17,24,39,.04);
}

.panel h3{
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 800;
}

.panel p{
  margin: 0 0 12px 0;
  font-size: 12px;
  color: var(--muted);
}

.action-btn{
  display:block;
  width: 100%;
  text-align:center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background:#fff;
  text-decoration:none;
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
  margin-top: 8px;
}

.action-btn.primary{
  background: var(--primary);
  border-color: rgba(79,70,229,.35);
  color: #fff;
}

.action-btn:hover{ background: rgba(17,24,39,.04); }
.action-btn.primary:hover{ background: var(--primary-2); }

/* --- general buttons/links --- */
.link{
  color: var(--primary);
  font-weight: 800;
  text-decoration:none;
}
.link:hover{ text-decoration: underline; }

/* responsive */
@media (max-width: 1100px){
  .module-grid{ grid-template-columns: 1fr; }
  .row{ grid-template-columns: 1fr; }
}

/* =========================
   Project expanded sidebar
   ========================= */

.project-nav{
  margin: 10px 0 14px 0;
}

.project-nav-header{
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0,0,0,.03);
}

.project-nav-title{
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
}

.project-nav-subtitle{
  margin-top: 4px;
  font-size: 11px;
  opacity: .75;
  line-height: 1.2;
}

.project-nav-items{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.project-step{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}

.project-step:hover{ background: rgba(0,0,0,.04); }
.project-step.active{ background: rgba(99,102,241,.12); }

.project-step .dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.25);
  flex: 0 0 auto;
}
.project-step.active .dot{ background: var(--primary); }

.project-nav-divider{
  height: 1px;
  background: var(--border);
  margin-top: 12px;
}

/* =========================
   Projects grid (ONE definition)
   - max 3 per row
   - equal height cards
   ========================= */

.project-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); /* max 3 per row */
  gap: 12px;
  align-items: stretch; /* equal height within each row */
}

/* 2 per row on medium screens */
@media (max-width: 1200px){
  .project-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 1 per row on small screens */
@media (max-width: 760px){
  .project-grid{ grid-template-columns: 1fr; }
}

.project-card-wrap{ min-width: 0; }

/* Your project cards re-use module-card; keep the hover feel here */
.project-card.module-card{
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 170px; /* baseline; tweak if you want taller */
  border: 1px solid var(--border);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.project-card.module-card:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.10);
  border-color: rgba(79, 70, 229, 0.35);
}

/* Right-side header actions (tag + trash) */
.project-card-actions{
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Hide trash until hover */
.trash-form{
  margin: 0;
}
.trash-btn{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.08);
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease, border-color 120ms ease;
}

.project-card:hover .trash-btn{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.trash-btn:hover{
  border-color: rgba(239, 68, 68, 0.45);
}

/* Platform icons row */
.platform-icons{
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  min-height: 22px; /* keeps layout stable even with none */
}

.platform-icons.muted{
  color: var(--muted);
  font-size: 12px;
}

.platform-icon{
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.platform-icon img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.15s ease;
}

.project-card:hover .platform-icon{
  opacity: 1;
}

.project-card:hover .platform-icon img{
  transform: scale(1.05);
}

/* Optional: keep descriptions from making cards feel wildly different */
.project-card .module-desc{
  margin-top: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Optional: spacing helper if you ever add a footer section */
.project-card .card-footer{
  margin-top: auto;
}

/* =========================
   Loading overlay (global)
   ========================= */
.loading-overlay{
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.show{
  display: flex;
}

.loading-modal{
  width: min(420px, calc(100vw - 40px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 18px 50px rgba(17,24,39,.20);
  text-align: center;
}

.spinner{
  width: 42px;
  height: 42px;
  margin: 0 auto 10px auto;
  border-radius: 999px;
  border: 4px solid rgba(17,24,39,.15);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}

@keyframes spin{
  to { transform: rotate(360deg); }
}

.loading-title{
  font-weight: 900;
  font-size: 14px;
  margin-top: 4px;
}

.loading-subtitle{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
