:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2d3150;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #3b82f6;
  --pink: #ec4899;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

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

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 260px;
  height: 100vh;
  background: #1a1d27;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
  z-index: 101;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #6c63ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.sidebar-logo p {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 6px;
}

.sidebar-stats {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.stats-bar {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  padding: 6px 0;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-label {
  color: var(--text-muted);
  flex: 1;
}

.stat-count {
  font-weight: 700;
  color: var(--text);
  min-width: 30px;
  text-align: right;
}

/* ── TABS IN SIDEBAR ── */
.sidebar-tabs {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.tab-switcher {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tab-btn {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
  letter-spacing: 0.2px;
  text-align: left;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--accent2);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── CONSOLIDATED SIDEBAR ── */
.sidebar-filters {
  padding: 16px;
}

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  transition: all 0.15s;
}

.filter-item:hover {
  border-color: var(--accent2);
  color: var(--text);
}

.filter-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-count {
  background: rgba(0,0,0,0.25);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ── TOP NAV ── */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  position: sticky;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover { color: var(--text); border-color: var(--accent2); }
.nav-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

.nav-search {
  flex: 1;
  max-width: 400px;
  margin-left: 20px;
}

input[type="search"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

input[type="search"]:focus {
  border-color: var(--accent);
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.filter-btn:hover {
  border-color: var(--accent2);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.sidebar-sort {
  padding: 0 16px 16px;
}

.sort-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  transition: all 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.sort-select:focus {
  border-color: var(--accent);
}

/* ── MAIN CONTENT AREA ── */
.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
  padding: 32px 32px 60px;
}

.anomaly-banner {
  background: linear-gradient(135deg, #2d1a1a, #3d1f0a);
  border: 1px solid #7c3d0a;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.anomaly-banner h3 {
  color: var(--orange);
  font-size: 0.9rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.anomaly-item {
  font-size: 0.83rem;
  color: var(--text-muted);
  padding: 8px 0;
  border-top: 1px solid #4a2a0a;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.anomaly-item code {
  background: #4a2a0a;
  color: #fbbf24;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: all 0.2s;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: var(--accent2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card.hidden { display: none; }

.card-status-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.card-name {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.card-badges {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  margin-left: 8px;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-en-proceso { background: #431407; color: #fb923c; border: 1px solid #7c2d12; }
.badge-publicado { background: #14532d; color: #86efac; border: 1px solid #166534; }
.badge-por-iniciar { background: #450a0a; color: #f87171; border: 1px solid #7f1d1d; }

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
  min-height: 36px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.meta-item svg { flex-shrink: 0; }

.tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.tech-tag {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.card-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.card-link {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-block;
}

.card-link:not(.disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 99, 255, 0.1);
}

.card-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.card-link.disabled:hover {
  border-color: var(--border);
  color: var(--text-muted);
  background: transparent;
}

.sheet-link { --link-color: #a78bfa; }
.repo-link { --link-color: #22c55e; }
.prod-link { --link-color: #f97316; }

.card-link:not(.disabled) { border-color: var(--link-color); }
.card-link:not(.disabled):hover { color: var(--link-color); border-color: var(--link-color); background: transparent; }

.suggestion-box {
  margin-top: 8px;
  background: var(--surface2);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-left: 3px solid var(--accent);
}

.suggestion-box.warn { border-left-color: var(--yellow); }
.suggestion-box.danger { border-left-color: var(--red); }
.suggestion-box.success { border-left-color: var(--green); }
.suggestion-box.info { border-left-color: var(--blue); }

.no-results {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-dim);
  padding: 60px 0;
  font-size: 0.9rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-stats {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  body {
    flex-direction: column;
  }

  .main-content {
    margin-left: 0;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

/* ── GITHUB CARDS ── */
.gh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gh-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.gh-card-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.gh-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent2);
  padding-top: 6px;
}
.gh-card-name a { color: inherit; text-decoration: none; }
.gh-card-name a:hover { text-decoration: underline; }
.gh-badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.gh-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.gh-badge.pub  { background: #0d2a1a; color: #4ade80; border: 1px solid #166534; }
.gh-badge.priv { background: #1e1030; color: #c084fc; border: 1px solid #581c87; }
.gh-badge.fork { background: #0d1e35; color: #60a5fa; border: 1px solid #1e3a5f; }
.gh-badge.arch { background: #2a200a; color: #fbbf24; border: 1px solid #92400e; }
.gh-badge.profile { background: #0a2525; color: #34d399; border: 1px solid #065f46; }
.gh-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
  min-height: 16px;
}
.gh-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.gh-card-date { font-size: 0.75rem; color: var(--text-dim); }
.gh-repo-link {
  font-size: 0.75rem;
  color: var(--accent2);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.gh-repo-link:hover { color: #fff; }
